Following what I thought was an issue with $this->uri->segment(), I figured out that it is actually a routing issue. Problem is that I can't really figure out what is wrong, as it looks exactly like another route I am using, which works fine, except this one has two variable segments, rather than one (for the route that is working).
The file I am trying to show is located in:
[main folder]/application/views/tasks/calendar/calendar.php
And I can load it with the command:
$route['tasks/calendar'] = 'tasks/calendar';
However, when I want to pass the current year and month as the last two segments, it does not work:
$route['tasks/calendar/(:num)/(:num)'] = 'tasks/calendar/$1/$2';
To my knowledge this should mean that a link like this should work:
(...)/index.php/tasks/calendar/2015/03
However, it does not. The full routes.php looks like this:
$route['auth/(:any)'] = 'auth/view/$1';
$route['auth'] = 'auth';
$route['projects/delete/(:any)'] = 'projects/delete/$1';
$route['projects/create'] = 'projects/create';
$route['projects/(:any)'] = 'projects/view/$1';
$route['projects'] = 'projects';
$route['(:any)'] = 'pages/view/$1';
$route['default_controller'] = 'pages/view';
$route['category'] = 'category';
$route['category/(:any)'] = 'category/view/$1';
$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';
And my controller, tasks.php, looks like this:
public function calendar($year = null, $month = null) {
// 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);
// Set variables for $data array
$data['year'] = $year;
$data['month'] = $month;
// Show page, including header and footer
$this->load->view('templates/header', $data);
$this->load->view('tasks/calendar', $data);
$this->load->view('templates/footer');
}
And the very simple view file, calendar.php, looks like this:
<?php
echo "Selected year: ".$year." and month: ".$month;
echo $this->calendar->generate($year, $month);
What the heck am I doing wrong? The delete routes for projects works just fine...