繁体   English   中英

在CodeIgniter中找不到错误页面的错误页面操作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'] ...第一件事就是确保$this->data['halaman_item']确实有数据...因为如果没有,它会先调用show_404发生。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM