带有多个页面的Codeigniter GET ID


Codeigniter GET ID with multiple page

我用Codeigniter框架做了一个网站,我搜索了多个页面,在URL中有相同的数据,但我不知道它是如何调用的。

例如,我的用户配置文件(user/profile)具有ID (user/profile?id=2)。但我想,另一个页面具有相同的信息看起来像user/profile?id=2/maps,例如,因为user/maps?id=2是复杂的,不逻辑..

怎么做到的?它叫什么?

另一个小问题,如何用Username替换"2"?如user/handleruser/handler/maps ?

您可以使用User控制器和profile()函数在codeigniter中进行简单的函数调用。你可以参考下面的代码:

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        
}

所以你可以像这样调用

http://your_base_url/user/profile/2
http://your_base_url/user/profile/2/map
如果有任何问题请告诉我。

@Zeeshan,谢谢你的回答。实际上,我的控制器是这样的:

类User扩展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');
}

$id=0,$page= "是什么?

谢谢