【问题标题】:Advance CodeIgniter pagination高级 CodeIgniter 分页
【发布时间】:2010-12-16 18:16:23
【问题描述】:

我使用 CodeIgniter 默认分页创建了图片库。图片来自db,每页16张图片。

最近,我的客户要求我在除第一页之外的每页中放置 32 张图片。 这意味着在第一页上它只有 16 个图像,而其他页面之后每页有 32 个图像。所以我稍微修改了代码,得到了他要求的结果。

但问题出在分页栏上。当我在第 2 页时,仍然分页显示我在第 1 页。

if ($this->uri->segment(3, 0) == 0){
    $config['per_page'] = 16;
    }else{
    $config['per_page'] = 32;
    }
    $config['num_links'] = 1;
    $this->pagination->initialize($config);


    $query = $this->db->get('img', $config['per_page'], $this->uri->segment(3));//when i am in page 2 "segment(3)" will equal to 16

他们还有其他可以做到这一点的替代分页库吗?该页面位于http://vintagepostersofceylon.com/posters/cinema/

【问题讨论】:

    标签: php codeigniter pagination


    【解决方案1】:

    试试$config['uri_segment']试试4

    如果你还是不明白,如果你给我们网址会有所帮助。

    更新:新信息

    我很困惑,为什么它不起作用。试试这个:

    if (((int)$this->uri->segment(3)) > 16)
    {
        $config['per_page'] = 32;
    }
    else
    {
        $config['per_page'] = 16;
    }
    
    $this->pagination->initialize($config);
    

    【讨论】:

    • 我看不到您发布的网址。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-09-11
    • 1970-01-01
    • 2015-12-28
    • 1970-01-01
    相关资源
    最近更新 更多