Tuesday, March 22, 2016

Creating a Calendar using Codeigniter - Tutorial 2

Setting Display Preferences


There are seven preferences you can set to control various aspects of the calendar. Preferences are set by passing an array of preferences in the second parameter of the loading function. Here is an example:

$prefs = array(
        'start_day'    => 'saturday',
        'month_type'   => 'long',
        'day_type'     => 'short'
);

$this->load->library('calendar', $prefs);

echo $this->calendar->generate();
The above code would start the calendar on saturday, use the “long” month heading, and the “short” day names.


Showing Next/Previous Month Links

To allow your calendar to dynamically increment/decrement via the next/previous links requires that you set up your calendar code similar to this example:

$prefs = array(
        'show_next_prev'  => TRUE,
        'next_prev_url'   => 'http://example.com/index.php/calendar/show/'
);

$this->load->library('calendar', $prefs);

echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));




No comments:

Post a Comment