Welcome Guest, Not a member yet? Register   Sign In
[solved] Calendaring customization [highlighting the current month]
#6

(This post was last modified: 11-28-2016, 09:07 AM by BabalooAye. Edit Reason: Include image to improve explanation )

(11-26-2016, 11:35 AM)InsiteFX Wrote: Yes, you can also extend the Calendar library with MY_Calendar

I extended the CI_Calendar and made the generate() method pass his $month variable to the parse_template($cur_month) method, then, he uses $cur_month to apply an exception and assign the class="info" to heading_row_start:

PHP Code:
        if (is_string($this->template)) {
            $today = array('cal_cell_start_today','cal_cell_content_today','cal_cell_no_content_today','cal_cell_end_today');            
            
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_day_cell''week_row_end''cal_row_start''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) {
                if (preg_match('/\{' $val '\}(.*?)\{\/' $val '\}/si'$this->template$match)) {
                    if($val == 'heading_row_start'){
                        if( $cur_month == date('m')){
                            $this->replacements[$val] = '<tr class="info">';
                        }
                    }
                    else{
                        $this->replacements[$val] = $match[1];
                    }
                }
                elseif (in_array($val$todayTRUE)) {
                    $this->replacements[$val] = $this->replacements[substr($val0, -6)];
                }
            }
        

Result:

[Image: Screen_Shot_2016_11_26_at_15_30_10_fullpage.png]
Reply


Messages In This Thread
RE: Calendaring customization [highlighting the current month] - by BabalooAye - 11-26-2016, 12:29 PM



Theme © iAndrew 2016 - Forum software by © MyBB