I am trying to get the CodeIgniter calender library to work, and for that I need to use $this->uri->segment(), according to the documentation at least. The url for the calender looks like this:
Which means, as far as I can understand, that $this->uri->segment(3) would be the year, and $this->uri->segment(4) the month. However, both of these returns nothing at all, here is the code for my calender page:
echo "Selected year: ".$this->uri->segment(3)." and month: ".$this->uri->segment(4);
echo $this->calendar->generate($this->uri->segment(3), $this->uri->segment(4));
The first line is merely used for debugging purposes, and confirms that none of the commands returns any output. The calender library is loaded in the controller, with the following code:
public function calendar() {
// Calender configuration (must be done prior to loading the library
$conf = array(
'start_day' => 'monday',
'show_next_prev' => true,
'next_prev_url' => base_url() . 'index.php/tasks/calendar'
);
// Load libraries and helpers
$this->load->library('calendar',$conf);
// Show page, including header and footer
$this->load->view('templates/header', $data);
$this->load->view('tasks/calendar', $data);
$this->load->view('templates/footer');
}
Can anyone tell me where I am failing? I read the documentation over and over again, and checked my code, but I can't see what I do different than their example?
UPDATE
I think I have ruled out that the problem is related to the $this->uri->section() function. Is likely to do with the controller loading an incorrect page, when additional sections is added to the URL after .../tasks/calendar/(...). I still haven't found a solution, but I wanted to let you know, in case others who read this had the same issue.
UPDATE 2
I think it might be a routing issue, the routes.php looks like this, for anything related to tasks:
$route['tasks/create'] = 'tasks/create';
$route['tasks/calendar/(:num)/(:num)'] = 'tasks/calendar/$1/$2';
$route['tasks/calendar'] = 'tasks/calendar';
$route['tasks'] = 'tasks';
$route['tasks/(:any)'] = 'tasks/view/$1';
$this->uri->segment()which is the issue... If anyone is interested, it can be found here - Jakob Busk Sørensen