CodeIgniter Forums
Undocumented features of the Pagination Class - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Undocumented features of the Pagination Class (/showthread.php?tid=40338)



Undocumented features of the Pagination Class - El Forum - 04-05-2011

[eluser]spider pig[/eluser]
I have been writing a blog where the post, comments form and comments are on the same page.

The problem I had was when I used the Pagination class for the comments, the next page of comments would load but it would load at the top of the page - where the post is and not at the comments at the bottom of the page.

Normally you would use an anchor to jump to the correct section but I could not see how to do this with the Pagination Class documentation. However, looking at the class code, I noticed some more options - "prefix" and "suffix". These are placed inside the links, so:

Code:
$config['suffix'] = '#comments_list';

adds the anchor link to the end of the URL:

Code:
<a href="/news/article/2009/07/21/First_Entry/10#comments_list">3</a>

Of course a better solution would be to use ajax to load the page of comments rather than re-loading the page. Maybe that's for the next version Smile