nrs jayaram
nrs jayaram

Reputation: 3448

How to fill previus and next months days in current month empty cell by codeigniter calendar Library

I am using Codeigniter calendar to display user events in webpage, the issue is displaying empty cells without date. i displayed my screenshot below.

enter image description here

In the above image I dotted by blue the empty cells, so here I want to display previous and next months day with a different color. How can I do this?

My sample CI Calendar Lib code is:

public function myCalendar($year = null, $month = null)
{
    $config = array(
                    'start_day' => 'monday',
                    'show_next_prev' => 'TRUE',
                    'day_type' => 'short',
                    'next_prev_url' => base_url().'testSiteC/myCalendar'
                );
                $events = array(
                    '1' => 'my birthday',
                    '10' => 'test'
                );
                $config['template'] = '
                {table_open}<table border="0" cellpadding="0" cellspacing="2" class="calendar_table_big">{/table_open}

                {heading_row_start}<tr>{/heading_row_start}

                {heading_previous_cell}<th><a href="{previous_url}"><img src="assets/images/trainer/solid_left_arrow.png" height="15" /></a></th>{/heading_previous_cell}
                {heading_title_cell}<th colspan="{colspan}">{heading}</th>{/heading_title_cell}
                {heading_next_cell}<th><a href="{next_url}"><img src="assets/images/trainer/solid_right_arrow.png" height="15" /></a></th>{/heading_next_cell}

                {heading_row_end}</tr>{/heading_row_end}

                {week_row_start}<tr class="week_row">{/week_row_start}
                {week_day_cell}<td>{week_day}</td>{/week_day_cell}
                {week_row_end}</tr>{/week_row_end}

                {cal_row_start}<tr class="cell_row">{/cal_row_start}
                {cal_cell_start}<td>{/cal_cell_start}
                {cal_cell_start_today}<td>{/cal_cell_start_today}
                {cal_cell_start_other}<td class="other-month">{/cal_cell_start_other}

                {cal_cell_content}<a href="{content}">{day}</a>{/cal_cell_content}
                {cal_cell_content_today}<div class="highlight"><a href="{content}">{day}</a></div>{/cal_cell_content_today}

                {cal_cell_no_content}{day}{/cal_cell_no_content}
                {cal_cell_no_content_today}<div class="highlight">{day}</div>{/cal_cell_no_content_today}

                {cal_cell_blank}&nbsp;{/cal_cell_blank}

                {cal_cell_other}{day}{cal_cel_other}

                {cal_cell_end}</td>{/cal_cell_end}
                {cal_cell_end_today}</td>{/cal_cell_end_today}
                {cal_cell_end_other}</td>{/cal_cell_end_other}
                {cal_row_end}</tr>{/cal_row_end}

                {table_close}</table>{/table_close}
                ';
                $this->load->library('calendar', $config);
                $data['minicalendar'] = $this->calendar->generate($year, $month, $events);
                $this->load->view('testSite/myCalendar', $data);

    }

Upvotes: 3

Views: 982

Answers (1)

Tpojka
Tpojka

Reputation: 7111

In your $config array set element:

$config = array(
    'start_day' => 'monday',
    'show_next_prev' => TRUE,
    'day_type' => 'short',
    'next_prev_url' => base_url().'testSiteC/myCalendar',
    'show_other_days' => TRUE,// add this
);

Also, every of your boolean values should be without quotes (in case of 'FALSE' it won't work at all). Reference.

Upvotes: 1

Related Questions