错误页面找不到CodeIgniter中带有slug的操作URL

时间:2014-04-05 12:25:36

标签: php 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页面。你可能知道在哪里问题。

帮我做什么。谢谢。

1 个答案:

答案 0 :(得分:0)

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

相关问题