用户
 找回密码
 入住 CI 中国社区
搜索
查看: 1805|回复: 2
收起左侧

CI ,伪静态分页问题。。。。。。。。。

[复制链接]
发表于 2014-4-22 10:36:16 | 显示全部楼层 |阅读模式
http://WWW.XXXX.com/index/more/new.shtml/2
这是目前分页的样子
我想让它变成这个样子
http://WWW.XXXX.com/index/more/new/2.shtml

该怎么做,具体点,帮忙一下。
控制器:
function more($type ='good') {   
        $session = $this->m_index->get_session ();
        $view_datas ['uname'] = $session ['uname'];   
        $type = $type ? $type : 'new';
        $count = $this->m_index->counts ( 'essay' );
        $this->load->library ( 'pagination' );
        $config ['base_url'] = site_url("index/more/".$type);
        $config ['total_rows'] = $count;
        $config ['per_page'] = 6;
        $config ['uri_segment'] = 4;
        $config ['full_tag_open'] = '<p style="float:right; margin-right:30px;">';
        $config ['full_tag_close'] = '</p>';
        $config ['last_link'] = '尾页';
        $config ['first_link'] = '首页';
        $config ['next_link'] = '下一页';
        $config ['prev_link'] = '上一页';
        $page=(int)$this->uri->segment ( 4 );   
        $start = $page ? $page : 1;
        $start = $start * 6 - 6;
        $config ['use_page_numbers'] = TRUE;
        $this->pagination->initialize ( $config );
        $view_datas ['pages'] = $this->pagination->create_links ();
        $view_datas ['datas'] = $this->m_index->more ( $type, $start, $config ['per_page'] );
        $this->load->view ( 'more', $view_datas );
    }

发表于 2014-4-22 11:36:35 | 显示全部楼层
本帖最后由 yggdrasil 于 2014-4-22 11:37 编辑

在config.php $config['url_suffix'] 加上.html 就可以了 伪静态

分页的话你这样试试 $config ['total_rows'] =$this->db->count_all_results('表名');
$config ['per_page'] = $prepage; // 个人是单独设置成一个变量 $prepage = 6;

$page=(int)$this->uri->segment ( 4 ); //偏移
$this->db->limit('$prepage',$page); //起始,取的条数

好了..去模板上 echo $pages 看看

本版积分规则