CodeIgniter Forums
Pagination: page not last part of uri - 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: Pagination: page not last part of uri (/showthread.php?tid=19910)



Pagination: page not last part of uri - El Forum - 06-22-2009

[eluser]tsisson[/eluser]
I don't want to use the page as the last part of my uri while using the pagination class. Is this possible?

So the uri would be

Code:
http://site.com/page/phrase/

instead of

Code:
http://site.com/phrase/page/

and the pagination links are generated accordingly.


What would the $config['base_url'] be? Or what's the workaround?


Pagination: page not last part of uri - El Forum - 06-22-2009

[eluser]TheFuzzy0ne[/eluser]
You can configure which segment the pagination library should use, however, it's ill-advised, since you may find yourself coming up against some unexpected design and implementation problems.


Pagination: page not last part of uri - El Forum - 06-22-2009

[eluser]Colin Williams[/eluser]
Quote:$config['uri_segment'] = 3;

The pagination function automatically determines which segment of your URI contains the page number. If you need something different you can specify it.

"Automatically determines" is probably not the best wording in the user guide. What it means is that it expects the pagination offset to be the 3rd uri parameter. You'll want to set it to 2


Pagination: page not last part of uri - El Forum - 06-22-2009

[eluser]tsisson[/eluser]
Maybe my question wasn't clear enough.

The problem are the pagination links. I don't know how they can be changed to the other format.


Pagination: page not last part of uri - El Forum - 06-22-2009

[eluser]Colin Williams[/eluser]
Ah.. I read your example backwards. You're saying you want links like

Code:
http://site.com/10/phrase/
http://site.com/20/phrase/

Is this correct? If so, there is no configuration you can do that will work because you are going against convention. The pagination class always does $config['base_url']/$offset. Your best bet is to overload the Pagination class as needed to meet your needs.

You could also, I suppose, doctor up the result of Pagination::create_links() with some regex replaces, but that's messy and ass-backward. I'd stick with rolling your own version.


Pagination: page not last part of uri - El Forum - 06-22-2009

[eluser]tsisson[/eluser]
Okay, thank you!