Pagination: Advanced library (SEO friendly first page, more tuning possibilities) |
[eluser]Unknown[/eluser]
Hello, I am just working on a new website and I needed to get more of Pagination library. I tried to find more suitable than the original one, but I failed. So I rewritten the original library "slightly". So what I've changed? What's new? 1) Pages are really pages, so expect 1st page with parameter 1, 2nd page with parameter 2, etc. (so don't look for offsets here :-) 2) SEO friendly link to the first page - 1st page has always the same link contained in $config['base_url'] directive 3) $config['num_links'] - the library will always try to show links to (2*$config['num_links']+1) pages if they are available. Example of 7 pages, $config['num_links'] = 2: a) current page = 4: links to pages 2, 3, 4, 5, 6 will be shown ("4" won't be a link) b) current page = 2: links to pages 1, 2, 3, 4, 5 will be shown ("2" won't be a link) c) current page = 1: links to pages 1, 2, 3, 4, 5 will be shown ("1" won't be a link) d) current page = 6: links to pages 3, 4, 5, 6, 7 will be shown ("6" won't be a link) If there are less then (2*$config['num_links']+1) pages there will be less links of course. 4) New possibilities (config directives): a) $config['first_link_enable'] = <boolean>; // turn on/off "< First" link (default = on) b) $config['last_link_enable'] = <boolean>; // turn on/off "Last >" link (default = on) c) $config['prev_link_enable'] = <boolean>; // turn on/off "< Prev" link (default = on) d) $config['next_link_enable'] = <boolean>; // turn on/off "Next >" link (default = on) And where it grows? (with readme file attached) http://www.myslivecek.net/ci/pagination.zip I'd really appreciate any comments (this is my 1st contribution to this kind of community so let me know if I did something wrong - such as versioning of the file / legal stuff / etc/)
[eluser]Johan André[/eluser]
You should extend (and override) the default pagination class and not put the file in the system-directory. Create a MY_Pagination.php and put it in application/libraries instead. Updating the core will be so much easier. ![]() Seems like good functionality though...
[eluser]Unknown[/eluser]
[quote author="Johan André" date="1282606731"]You should extend (and override) the default pagination class and not put the file in the system-directory. Create a MY_Pagination.php and put it in application/libraries instead. Updating the core will be so much easier. ![]() Seems like good functionality though...[/quote] Thanks for helping me to overcome my laziness :-) I've "reworked" it so that it should be as you suggested (except of the name of the class). + I've added support for negative number in $config['uri_segment']. If you use "-1" value the pagination library will look for page number in the last uri segment ("-2" -> the last but one, etc.) I found "pagination part" of URI as the least important part, so I'm used to have it as the last. I know you can solve it in URI routing, but maybe someone will find it usefull (I certainly will :-) Updated version can be found at the same link... |
Welcome Guest, Not a member yet? Register Sign In |