[3.1.4 modification] modify calendar library, add extra column before calendar |
i love the calendar library, but i just miss a single feature. i need to add a column before or after the calendar for (for example) the weeknumber or other thing relevant for that week.
Is there any way to modify the calendar library (by copying it to my own library folder and modify it) to allow for an extra column before the first or after the last column with a way to add data into it ofcourse....
I've done a lot of work extending the calendar class. Yes, you will create a MY_calendar.php. You will spend quite a bit of time learning what's going on in the calendar class so that you can make your modifications.
Also, I ended up needing to extend the calendar class in two different ways, and so you should think about the modifications you are making, and remember that there may be a time when you don't want those specific mods to affect the calendar.
05-21-2017, 06:27 AM
(This post was last modified: 05-21-2017, 06:29 AM by ivantcholakov. Edit Reason: directory clarification )
A library under a different name could be an option to be considered:
Code: <?php defined('BASEPATH') OR exit('No direct script access allowed'); Code: // A Quick Test
05-22-2017, 12:46 PM
(This post was last modified: 05-22-2017, 12:53 PM by eagle00789. Edit Reason: added screenshot )
if you want a quick and dirty method like me, you can do the following:
the mentiond line numbers represent the original line numbers from the original calendar.php file. that is why the changes are in reverse order, from the bottom up: Copy the system/libraries/calendar.php file to Application/libraries/MY_calendar.php Go to line 526 and replace it with the following text: PHP Code: foreach (array('table_open', 'table_close', 'heading_row_start', 'heading_previous_cell', 'heading_title_cell', 'heading_next_cell', 'heading_row_end', 'week_row_start', 'week_row_before_cell', 'week_day_cell', 'week_row_end', 'cal_row_start', 'cal_row_before', 'cal_cell_start', 'cal_cell_content', 'cal_cell_no_content', 'cal_cell_blank', 'cal_cell_end', 'cal_row_end', 'cal_cell_start_today', 'cal_cell_content_today', 'cal_cell_no_content_today', 'cal_cell_end_today', 'cal_cell_start_other', 'cal_cell_other', 'cal_cell_end_other') as $val) PHP Code: if (array_key_exists('cal_row_before', $this->replacements)) PHP Code: if (array_key_exists('cal_row_before', $this->replacements)) PHP Code: if (array_key_exists('cal_row_before', $this->replacements)) PHP Code: if (array_key_exists('week_row_before_cell', $this->replacements)) PHP Code: class MY_Calendar extends CI_Calendar { PHP Code: $this->load->library('calendar', $prefs); Now you can use the following fields in your template (with examples included) PHP Code: {week_row_before_cell}<td> </td>{/week_row_before_cell} The field cal_row_before is the extra cell before each week row. In this field, you can use the fields from_day and to_day to use the first and last day of that week in your extra cell. View a demo (partial screenshot) below: |
Welcome Guest, Not a member yet? Register Sign In |