我的CodeIgniter分页模块有问题。
当我去点击链接时,我得到一个404错误。正如我所理解的,我可能是不正确的,但似乎确定偏移量的URI段没有在我的控制器的索引函数中读取,代码点火器实际上是在控制器内部寻找这个函数,因此当它找不到它时抛出404。
我已经在论坛上搜索并检查了一个解决方案,但没有任何成功。如果有人有任何提示或提示,那将是伟大的,我已经包括了相关的代码从我的控制器,模型和视图下面。
//控制器$this->load->library('pagination');
$config['base_url'] = '/yourhistory/';
$config['total_rows'] = $this->db->get('gallery')->num_rows();
$config['per_page'] = 3;
$config['uri_segment'] = 2;
$this->pagination->initialize($config);
$data['galleryitems'] = $this->pages_model->get_gallery($config['per_page'], $config['uri_segment']);
$this->load->view('/gallery', $data);
//模型function get_gallery($limit, $segment)
{
$query = $this->db->get('gallery', $limit, $this->uri->segment($segment));
if ($query->num_rows > 0)
{
foreach($query->result() as $row)
{
$data[] = $row;
}
return $data;
}
}
//视图 echo $this->pagination->create_links();
因为base_url:
它首先会失败$config['base_url'] = 'http://example.com/index.php/test/page/';
你需要完整的路径,虽然我只是猜测这里,因为你没有提供抛出404的URL。
此处的分页说明:http://codeigniter.com/user_guide/libraries/pagination.html
您的base_url不正确:
<>之前//应该是这样的$config['base_url'] = base_url().'/controllername/functionname/';之前见:http://codeigniter.com/user_guide/libraries/pagination.html