I make a site with Codeigniter framework and I search to make multiple page with the same data in URL but I don't know how its call..
I have my user profile (user/profile
) with an ID (user/profile?id=2
) for example. But I want, another page with the same information look like user/profile?id=2/maps
for example, because user/maps?id=2
was complicated an not logic..
How make this? How its call?
Another small question, how replace "2" by Username? like user/handler
or user/handler/maps
?
You can make if simple function call in codeigniter with User
controller and profile()
function.For reference you can refer below code :
class User extends CI_Controller {
public function __construct()
{
parent::__construct();
}
public function profile($id=0,$page='')
{
//do your logic here depending on the parameters above
}
So you can simply call like this
http://your_base_url/user/profile/2
http://your_base_url/user/profile/2/map
Let me know in case of any queries.
Thanks for your answer @Zeeshan. Actually, my controllers look like this:
class User extends CI_Controller {
public function profil()
{
// Récupération de l'ID dans l'url
$this->data['id'] = $this->input->get('id', TRUE);
// Statistiques du profil
$this->data['countReview'] = $this->review_model->countReview($this->data['id']);
// Chargement du profil de l'utilisateur
if (ctype_digit($this->data['id'])) {
if ($this->user_model->getUser($this->data['id'])) {
$this->data['users'] = $this->user_model->getUser($this->data['id']);
$this->data['reviewsNext'] = $this->review_model->getReviewsByUser_Next($this->data['id']);
$this->data['reviewsPrevious'] = $this->review_model->getReviewsByUser_Previous($this->data['id']);
} else {
$this->session->set_flashdata('error', 'Utilisateur introuvable.');
redirect(site_url());
}
} else {
$this->data['error_report'][] = "Utilisateur introuvable.";
redirect(site_url());
}
$this->load->view('template/header');
$this->load->view('template/menu');
$this->load->view('user/profil', $this->data);
$this->load->view('template/footer');
}
And what is the $id=0,$page='' ?
THanks