Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Can I change the page number location in Pagination links?
  • I am writing an application that passes a user query via GET to a database and then displays the results in a table. I want to use the Pagination class to page through the results. But my page links need to maintain the query parameters, so that the results set remains constant as the user pages.

    I'd like for my pager links to resemble the following:

    link for page 1: http://mysite.com/myapp/1?param1=foo&param2=bar
    link for page 2: http://mysite.com/myapp/2?param1=foo&param2=bar
    link for page 3: http://mysite.com/myapp/3?param1=foo&param2=bar

    The Pagination object seems to append a slash and the page number to the very end of the URL no matter what I do. I realize that I can make the page number a GET parameter, like the following:

    http://mysite.com/myapp?param1=foo&param2=bar&page=/2

    ...and then pass the current page into the Pager object from my GET input. But I'm not wild about the unnecessary '/' before the page number.

    I've poked around in core/classes/pagination.php, and the inflexible line seems to be 279:

    $url = ($i == 1) ? '' : '/'.$i;

    Is there an easy way for me to get what I want, without my having to clone the pagination class and rewrite the way it generates URLs?

    Kevin M
  • HarroHarro
    Accepted Answer
    This has been fixed in 1.6/develop (support for query strings in pagination URL's).

    Backporting it to a previous Fuel version should be possible, but not easy because it has changed quite a bit.
  • Thank you for the information, Harro. That's very helpful.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion