【问题标题】:Why CodeIgniter Pagination Link Bloats?为什么 CodeIgniter 分页链接膨胀?
【发布时间】:2012-05-06 20:10:00
【问题描述】:

我花了一些时间,但无法弄清楚出了什么问题。我正在使用 CodeIgniter 2.1.0。

所以基本上是这样的:

我的分页设置:

$config['base_url'] = base_url() . '/stores/';
$config['total_rows'] = $this->stores_model->getTotalRows();
$config['per_page'] = 20; //display 20 rows per page
$config['num_links'] = 10; //display 10 pagination links
$config['uri_segment'] = 2;
$config['full_tag_open'] = '<div id="pagination">';
$config['full_tag_close'] = '</div>';
$this->pagination->initialize($config);

我正在从控制器获取这样的数据块。这也有效。

$data['stores'] = $this->stores_model->getChunks($config['per_page'], $this->uri->segment(2));

我的浏览页面有:

<?php echo $this->pagination->create_links(); ?>

现在一切正常。起初显示了 10 个分页链接,但是当我单击链接 8、9 或 10 等时,分页链接会膨胀。它现在显示链接 1 到 20。这是为什么呢?这可能是非常简单的事情,但似乎无法弄清楚。我期待分页链接的滚动,但只显示了 10 个链接,因为我在配置中设置了。

感谢和问候

迪帕克

【问题讨论】:

    标签: .htaccess routing pagination codeigniter-2


    【解决方案1】:

    现在我明白了

    $config['num_links'] 让我困惑了一阵子。

    这表示在当前链接两侧(上一个和下一个)显示的链接数。

    ie. (show prev 10 links from current) <----- [current page] -----> (show next 10 links from current)
    

    将它设置为 5 解决了这个问题。现在我总共有大约 11 个链接按预期显示。

    再次感谢

    迪帕克

    【讨论】:

      猜你喜欢
      • 2021-07-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-05-13
      • 2019-01-06
      • 2012-06-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多