CodeIgniter 2.0.3 Pagination 类起始页
我试图使用 codeigniter 分页类。
这是我的代码
$this->load->library('pagination');
$config['base_url'] = base_url('language/'.$this->uri->segment(2));
$config['total_rows'] = $page_count;
$config['per_page'] = 1;
$config['num_links'] = '2';
$config['uri_segment'] = '2';
$this->pagination->initialize($config);
$data['pages'] = $this->pagination->create_links();
,但是在第一页中,网址看起来像,
localhost/language/something/
而第二页看起来
localhost/language/something/1
有点奇怪,是否可以在第一页上让网址以 1 开头?
I was trying to work with the codeigniter pagination class.
Here is my code
$this->load->library('pagination');
$config['base_url'] = base_url('language/'.$this->uri->segment(2));
$config['total_rows'] = $page_count;
$config['per_page'] = 1;
$config['num_links'] = '2';
$config['uri_segment'] = '2';
$this->pagination->initialize($config);
$data['pages'] = $this->pagination->create_links();
but then, in the first page, the url would be look like
localhost/language/something/
while the second page would be
localhost/language/something/1
which looks kinda weird, is it possible to have the url starts with 1 on first page?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是覆盖内置分页类的代码。将其放入应用程序/库中,然后像平常一样执行其他操作。
我已经在原始类中编辑的每一行添加了注释。
注意:在示例代码中,您将总页数放入total_rows 配置值中。请务必输入记录总数,而不是总页数。
Here is the code to override the built in pagination class. Place it in application/libraries and just do everything else like normal.
I've added a comment to each line I edited from the original class.
NOTE: in your sample code you put total pages in the total_rows config value. Be sure to put the total number of records, not the total number of pages.
URL 中的数字不是页码,而是记录偏移量。
例如,如果将其设置为每页 25 条记录:
第 1 页的 URL 将是这样:
第 2 页将是这样:
第 3 页...
The number in the URL is not the page number, it is the record offset.
For example, if you set it to 25 records per page:
The URL for page 1 would be this:
and page 2 would be this:
and page 3...