在代码点火器中找不到带有 slug 的操作 URL 的错误页面


Error page not found manipulation URL with slug in CodeIgniter

当我使用 slug 实现 URL 时,我找不到错误页面。

这是控制器中的代码

function view($slug)
{
    $this->data['halaman_item'] = $this->mhalaman->get_profil($slug);
    if (empty($this->data['halaman_item'])) {
        show_404();
    }
    $this->data['title'] = $this->data['halaman_item']['judul'];            $this->data['orang'] = $this->mlogin->dataPengguna($this->session->userdata('username'));
    $this->data['contents'] = $this->load->view('mahasiswa/profil/sejarah', $this->data, true);
    $this->load->view('template/wrapper/mahasiswa/wrapper_content',$this->data);
}

function get_profil($slug = FALSE)
{
    if ($slug === FALSE)
    {
        $query = $this->db->get($this->tbl_halaman);
        return $query->result_array();
    }
    $query = $this->db->get_where($this->tbl_halaman, array('slug'=>$slug));
    return $query->row_array();
}

路线

$route['profil/view'] = "profil/view";
$route['profil/(:any)'] = "profil/view/$1";
$route['profil'] = "profil";

当我运行此链接时tkd/index.php/mahasiswa/profil/sejarah找不到404页面。 可能你知道问题出在哪里。

帮我做什么。谢谢。

好吧,不知道你的应用程序的其余部分有多少工作......第一个明显的事情是确保$this->data['halaman_item']里面确实有数据......因为如果没有,它会在任何事情发生之前调用show_404