codeigniter与uri路由分页

时间:2015-10-06 07:16:17

标签: codeigniter pagination routing

我的控制器是flex,我的功能名称是 post_blog 。我已为此函数$config['blog'] = 'flex/post_blog'完成了路由。直到这一切都运转良好。我添加了由上面的函数和我的$config['base_url'] = 'blog'加载的页面的分页。我的第一页上的一切都很好,但在第二页上显示的页面没有找到。

如何解决这个问题?

$this->load->library('pagination');
        if($this->uri->segment(2)){
        $page = ($this->uri->segment(2)) ;
        }
        else{
        $page = 1;
        }


        $config = array();
        $config['base_url'] = base_url('blog');
        $config['total_rows'] = $post_count;
        $config['per_page'] = 15;
        $config['num_links'] = 2;
        $config['use_page_numbers'] = TRUE;
        $config['cur_tag_open'] = '&nbsp;<a class="current"><b>';
        $config['cur_tag_close'] = '</b></a>';
        $config['next_link'] = 'Next';
        $config['prev_link'] = 'Previous';
        $offset=(($page-1)*$config["per_page"]) ;
        $this->pagination->initialize($config);
        $str_links = $this->pagination->create_links();
        $data['links'] = explode('&nbsp;',$str_links );

1 个答案:

答案 0 :(得分:0)

尝试

$config['base_url'] = base_url('controller_name/blog');
$config['uri_segment'] = 3;

同时删除echo $page;exit;

尝试将$config['num_links'] = 2;更改为$config['num_links'] = $post_count;