|
本帖最后由 不科学 于 2015-6-24 15:44 编辑
PHP复制代码 public function index ($tag = "2009")
{
$total = count($this->Blog_model->count_tag($tag));//获取当前分类的文章数量
$config['base_url']= site_url ().'/tag/index/'.$tag;
$config['total_rows']= $total ;
$config['per_page']= 20;
$this->pagination->initialize($config);
$data['items'] = $this->Blog_model->tag_items($tag, $config['per_page'], $this->uri->segment(4));//根据$limit、$offset取出文章
if (empty($data['items']))
{
show_404 ();
}
$data['cat_items'] = $this->Blog_model->category();
$data['page_links'] = $this->pagination->create_links();
$this->load->view('templates/header',$data);
$this->load->view('tag',$data);
} 复制代码
这是tag类的一个index方法
链接是这样:ci/index.php/tag/index/2010
理论上该页面应该是tag=2010时的第一页,实际显示是这样:
![](http://codeigniter.org.cn/forums/data/attachment/album/201506/23/182345rdyhlfyjtx5mhpap.png)
当我把链接手动改成ci/index.php/tag/index/2010/00时,就会正常显示在第1页。
几乎是相同的代码,只是具体参数不同,我写的category类就完全没问题。
|
|