Welcome Guest, Not a member yet? Register   Sign In
NOT WORKING: Showing three calendars with three different months

Hi everyone.

I am trying to make an events booking web application using CodeIgniter with HMVC. To do that I am making use of codeigniters calendaring class. I am trying to show three calendars like this...


So for example here I would like to show september - october - november, then if they clicked the arrow right it would show the next three months.

Okay, so down to business. Here is my Bookings controller as it stands (with comments).

PHP Code:
public function index($year null$month null$day null)
        if (empty($year)) {
            redirect('book/index/' date('Y/m/d'time()));


        // september
        $data['cal_one']   $this->Booking_Model->generateCalendar($year$month$day);
        // october
        $data['cal_two']   $this->Booking_Model->generateCalendar($yeardate('m'strtotime('+1 months')), $day);
        // november
        $data['cal_three'] = $this->Booking_Model->generateCalendar($yeardate('m'strtotime('+2 months')), $day);

        // to load the view
        $data['module'] = 'book';
        $data['view_file'] = 'select_date';

Here is my model that generates the calendar

PHP Code:
public function generateCalendar($year$month$day$student_id null)
= [
           'show_next_prev' => true,
           'next_prev_url'  => base_url() . 'schedule/index',
           'template'       => '
                {table_open}<table id="tt-calendar">{/table_open}


                            <th class="text-center">


                            <th class="text-center" colspan="{colspan}">

                            <th class="text-center">






                        {cal_cell_start_today}<td id="tt-calendar-today">{/cal_cell_start_today}

                        {cal_cell_start_other}<td id="tt-calendar-test">{/cal_cell_start_other}

                            <div class="day" href="" onclick="return getDate(' 
$year ' + /' $month '/ + {day});">
                                {day} ' 
$month '

                            <div class="day" href="" onclick="return getDate(' 
$year ' + /' $month '/ + {day});">
                                {day} ' 
$month '

                            <div class="day" href="" onclick="return getDate(' 
$year ' + /' $month '/ + {day});">
                                {day} ' 
$month '

                            <div class="day" href="" onclick="return getDate(' 
$year ' + /' $month '/ + {day});">
                                {day} ' 
$month '








       // loading the calendar and passing the params and data
       return $this->calendar->generate($year$month);

The problem here is that when I load calendar one (september) the library is loaded and ?cached? so that when I try and load calendar two (october), the dates are all for september.

How do I display multiple calendars side by side??

(This post was last modified: 09-19-2016, 11:43 PM by Avenirer.)

Could this be because you are not passsing the generate() method a valid integer? As i see you are passing date('m',strtotime(...)...)

'm' inside date() would return you with a number with "0" in front of it for months 1 to 9 (so, a string...). So maybe you should put 'n' instead of 'm' as the first parameter of date() or typecasting the value to an integer before passing it to the generate()?

Theme © iAndrew 2016 - Forum software by © MyBB