mehwish
mehwish

Reputation: 87

Calendar class in Codeigniter not showing next/previous months

I am trying to generate a calendar and almost have it, but when I click the next or previous links, the calendar is not displayed - otherwise it is correct. When I click the next url the address bar shows the correct url, but the next month is not shown.

Here is my code:

class Poll_controller1 extends skylark {

function poll_home()
{
    $this->add_to_center(POLL,"poll_view1");
    $this->load_lcr_template();
    $prefs = array (
           'show_next_prev'  => TRUE,
           'next_prev_url'   => 'http://skylarkv2/index.php/poll_controller1/show'
         );

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

function show()
{
    echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));
} 

Am I making mistake or missing something?

Upvotes: 1

Views: 1763

Answers (2)

nrs jayaram
nrs jayaram

Reputation: 3448

try this from controller

 public function display($year = null, $month = null)
    {
            $config = array(
            'show_next_prev' => 'TRUE',
            'next_prev_url' => base_url().'calendarC/display'
            );
            $this->load->library('calendar', $config);
            $data['calendar'] = $this->calendar->generate($year, $month);
            $this->load->view('calendar', $data);
    }

Upvotes: 1

No Results Found
No Results Found

Reputation: 102794

Most likely, you just need to initialize the calendar class in the same scope that you generate it. The way you have it set up, show() has no knowledge of how the class was initialized in poll_home(). Try something like this:

function show()
{
    $prefs = array (
       'show_next_prev'  => TRUE,
       'next_prev_url'   => 'http://skylarkv2/index.php/poll_controller1/show'
     );

    $this->load->library('calendar', $prefs);
    echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));
} 

There's also the chance that $this->uri->segment(3) and $this->uri->segment(4) are not what you think they are, double check that those values are correct. If you are have any routing going on, you may need to use $this->uri->rsegment() instead (note the r).

Upvotes: 0

Related Questions