我使用CodeIgniter默认分页创建了图库。图像来自数据库,每页有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/
答案 0 :(得分:0)
尝试使用$config['uri_segment']
尝试4
如果你仍然没有得到它,如果你给我们提供URL将会有所帮助。
更新:新信息
我很困惑,为什么它不起作用。试试这个:
if (((int)$this->uri->segment(3)) > 16)
{
$config['per_page'] = 32;
}
else
{
$config['per_page'] = 16;
}
$this->pagination->initialize($config);