[eluser]andychurchill[/eluser]
What I'm trying to achieve is something like this:
/people/ (shows a list of people)
/people/andy-churchill (shows andy-churchill's profile)
I've already got a rewrite rule to handle the index.php bit, so that I'm not having to call /index.php/people/ which works fine. What I have next is:
<?php
class people extends CI_Controller {
function people()
{
parent::__construct();
}
// Default action for people, list of people in A-Z order
function index($id = null)
{
if (!is_null($id))
{
$this->_showPerson($id);
return;
}
$this->load->view('header');
$this->load->view('peoplelist');
$this->load->view('footer');
}
private function _showPerson($slug)
{
// $data is set;
$this->load->view('header');
$this->load->view('person', $data);
$this->load->view('footer');
}
}
?>
So far it works fine for /people, but not when I try to add a parameter, I just get the CI 404 error. If I change the function name from "index" to "test" and then hit /people/test/ and /people/test/something, I get the expected results, but how do I make this work without having to specify "test", as in my original requirement?
Not sure if I need to add a wildcard to the route, or add a new route entry completely, or whether I'm doing something wrong and haven't quite understood what is possible. :S