I'm just learning codeigniter, and I seem to have run into something that is a little strange. I'm using the URI routing feature but need to get the URI segments of the re-routed URI.
This is one of the routes:
$route['content'] = "site/display/main template/content";
and when visiting http://lipsum.localhost/content
it loads the controller, but it won't let me use the URI class:
class Site extends Controller {
function display($template, $page) {
echo "display<br>";
$this->load->library('uri');
echo $this->uri->rsegment(1, 0)."<br>";
echo $this->uri->rsegment(2, 0)."<br>";
echo $this->uri->rsegment(3, 0)."<br>";
echo $this->uri->rsegment(4, 0)."<br>";
}
}
when I visit the page, it just displays
display 0 0 0 0
Basically this code should load a template and then pass $page
to it so it can load a section of a website. So 'content' might use 'main template' as the template, and then pass 'content' to it as the page to load. But I also want to be able to pass '/products/whatever' to it, etc -- so I want to cycle through the URI segments to get the full "path" to the page. How can I make it work? And, why is what I have not working?