CodeIgniter Pagination类阻止访问其他页面

时间:2013-12-02 20:06:01

标签: php codeigniter controller pagination

尝试自己这样做,但没有运气= / 我的主页是在主页上,我有一些博客系统, 该控制器上唯一的另一个视图是登录,在启用分页后,它就会消失,而现在不是URL / login,而是显示主页面。

我的控制器:

public function view($page = 'index') 
    {
        if ( !file_exists('application/views/pages/'.$page.'.php') || $page == 'header' || $page == 'footer')
        {
            // Whoops, we don't have a page for that!
            show_404();
        }
        if( $page = 'index' ) {
            $this->load->library('pagination');
            $config['base_url'] = base_url('posts');
            $config['total_rows'] = $this->db->order_by("id", "desc")->get('Updates')->num_rows();
            $config['per_page'] = 5;
            $config['uri_segment'] = 3;
            $config['full_tag_open'] = '<div id="pages">';
            $config['full_tag_close'] = '</div>';
            $this->pagination->initialize($config);
            $data['records'] = $this->db->order_by("id", "desc")->get('Updates', $config['per_page'], $this->uri->segment(2));
        } 
        $this->load->model('panel_model');
        $data['math_captcha_question'] = $this->mathcaptcha->get_question();
        $this->load->view('header');
        $this->load->view('pages/'.$page, $data);
        $this->load->view('footer');
    }

routes.php文件:

$route['login'] = "pages/view/login";

如果你们中的任何人能帮助我,我会很高兴的。)

谢谢!

1 个答案:

答案 0 :(得分:0)

base_url =资产,文件和目录。

site_url =您网站的网址,因为它附加了$ config ['index_page']。

尝试将base_url('posts')替换为site_url('posts');