我的型号代码
public function show_active_cat($limit,$offset) {
$query = $this->db->select()
->from('categories')
->where('status', 1)
->limit($limit, $offset)
->order_by('created', 'DESC')
->get();
return $query->result();
}
public function num_rows() {
$query = $this->db
->select('id,cat_name,parrent_id,status')
->from('categories')
->where('status',1)
->get();
return $query->num_rows();
}
控制器代码
public function categories($page = 'categories') {
if (!file_exists('application/views/public/' . $page . '.php')) {
show_404();
} else {
$this->load->library('pagination');
$config = [
'base_url' => base_url('pages/categories'),
'per_page' => 2,
'total_rows' => $this->categorymodel->num_rows(),
'uri_segment' => 3,
'full_tag_open' => "<ul class='pagination'>",
'full_tag_close' => "</ul>",
'first_tag_open' => '<li>',
'first_tag_close' => '</li>',
'last_tag_open' => '<li>',
'last_tag_close' => '</li>',
'next_tag_open' => '<li>',
'next_tag_close' => '</li>',
'prev_tag_open' => '<li>',
'prev_tag_close' => '</li>',
'num_tag_open' => '<li>',
'num_tag_close' => '</li>',
'cur_tag_open' => "<li class='active'><a>",
'cur_tag_close' => '</a></li>',
];
$this->pagination->initialize($config);
$data['cat_list'] = $this->categorymodel->show_active_cat($config['per_page'], $this->uri->segment(3));
$this->load->view('templates/public-header');
$this->load->view('public/categories',$data);
$this->load->view('templates/public-footer');
}
}
我的htaccess
<IfModule authz_core_module>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>
拒绝所有人
问题是,当我尝试单击panination链接以获取下一条记录时,网址为:http://192.168.1.66:2020/ci/pages/categories/2 信息: 找不到404页面
找不到您请求的页面。
答案 0 :(得分:0)
这里我找到了解决方案,当我删除if语句然后它工作正常
`if (!file_exists('application/views/public/' . $page . '.php'))
{
show_404();
}`