【问题标题】:Codeigniter Pagination without URI Segments没有 URI 段的 Codeigniter 分页
【发布时间】:2016-04-13 20:41:12
【问题描述】:

我正在构建一个图像评级应用程序,其中主页基本上是一个图像网格,每个图像底部都有简单的是/否投票按钮。

我在服务器端使用 Codeigniter,在界面使用 Bootstrap(CSS 和 JS)。

现在,我不想一次加载所有图片,而是将图片分成页面,每页包含 10 张图片以减少加载时间。

我一直在查看@The CI Docs 的文档,希望我使用此代码的变体:

$this->load->library('pagination');

$config['base_url'] = 'imgapp.com';
$config['total_rows'] = 100;
$config['per_page'] = 10; 

$this->pagination->initialize($config); 

echo $this->pagination->create_links();

产生这个:

问题是,我没有以启用 URI 段的方式构建它。

所以,这些链接毫无用处——它们指向的是这样的地址:

http://www.imgapp.com/default_controller/3

这对我没用。

如何配置分页以使用我的图像应用程序?

【问题讨论】:

    标签: codeigniter pagination


    【解决方案1】:

    检查http://ellislab.com/codeigniter/user-guide/libraries/pagination.html 配置分页的关键是:

    $config['uri_segment'] = 3;
    The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it.
    
    $config['base_url'] = 'http://example.com/index.php/test/page/';
    base_url This is the full URL to the controller class/function containing your pagination. In the example above, it is pointing to a controller called "Test" and a function called "page". Keep in mind that you can re-route your URI if you need a different structure.
    

    【讨论】:

    • 阅读问题 - 我已经看过了。
    猜你喜欢
    • 2012-06-07
    • 2011-03-02
    • 1970-01-01
    • 2016-01-03
    • 1970-01-01
    • 2020-10-27
    • 1970-01-01
    • 2012-11-26
    • 1970-01-01
    相关资源
    最近更新 更多