I love the way SO handles URIs. I'd like to mimic the same behaviour in CI. I have a controller called Users
and the index method should take one argument, that being the user ID. I search the DB for the username associated with that user ID. Consider that user:1
has username:Santa Claus
, how can I append the username to the URI, so that it looks like http://foo.com/users/1/santa-claus
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Users extends CI_Controller {
function index($uID = 0) {
if ($uID > 0) {
$this->load->model('users_model');
$uname = $this->users_model->_getUsername($uID);
#append somehow..
} else {
echo('load all users');
}
}
}
Just to be clear, I'm trying to achieve this: