简体   繁体   English

Codeigniter自定义分页链接

[英]Codeigniter customizing pagination links

I'm using CodeIgniter pagination,Consider 20 links pagination 我正在使用CodeIgniter分页,请考虑20个链接分页

Condition 1 : Show 5 links initially like below 条件1:最初显示5个链接,如下所示

1 2 3 4 5 next>>

Condition 2 : When 5th link is clicked, the number 5 should place two digits on either side like below 条件2:单击第5个链接时,数字5应该在两边各放两位,如下所示

<<previous 3 4 5 6 7 next>>

I have change 我有零钱

$config["num_links"] = 2;

this works fine for condition 2 but initially it gives 3 links like below. 这对于条件2很好用,但最初它提供了3个如下所示的链接。

 1 2 3 next>>

When num_links changed to 4 当num_links更改为4时

$config["num_links"] = 4;

this works fine for condition 1 but fail to meet condition 2 这对于条件1可以正常工作,但不能满足条件2

CodeIgniter does not have any inbuilt configuration for this. CodeIgniter没有为此的任何内置配置。

When you say: $config["num_links"] = 2; 当您说: $config["num_links"] = 2; it just means add 2 previous and 2 next to the current page. 这仅意味着在当前页面2 previous添加2 previous2 next

When you are in the first page, there is no previous and it adds two next so you get: 当您位于第一页时,没有上一页,并且在下一页添加了两个,因此您会得到:

1 2 3 next>>

Same logic for the behavior when you do $config["num_links"] = 4; $config["num_links"] = 4;时,行为的逻辑相同$config["num_links"] = 4;

If you really want to do it how you described you will have to extend the CI Pagination class with your own class: 如果您确实想按照自己的描述去做,则必须使用自己的类来扩展CI分页类:

class MY_Pagination extends CI_Pagination {...

And then add your custom pagination functions to it. 然后向其中添加您的自定义分页功能。

This link looks like an interesting read and may help you. 链接看起来很有趣,可以为您提供帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM