Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pagination class with GET query variables
  • How about adding some functionality to pagination class? I bet some people would like to use pagination with query variables like:
    site.com/blog/1?comments=2
    
  • Ok, still work in progress, but i modified Pagination class to accept GET variables.
    Here:
    https://github.com/CharlieBlack/fuel/commits/develop (can't send pull request, says that fork is up to date with main branch, going to contact support) Last two commits (still needs small bugfix).
    Input class also has to be updated to be able to use
    Input::get();
    

    How it works/
    Same as described in docs, but:
    'pagination_url' should be just segments - you don't have to include stuff like "?page=2".
    you also have to set query_variable like so:
    'query_variable' => 'page'
    

    In case if user has several GET query variables:
    all of variables will be saved and added automatically.
    For example let's say we have this page:
    site.com/blog/hello-world?page=1&comments=5
    

    if you'll go to the next page in blog, "comments" variable still will be there:
    site.com/blog/hello-world?page=2&comments=5
    

  • Ok, same link, 3 commits:
    https://github.com/CharlieBlack/fuel/commits/develop Looks like it works.

Howdy, Stranger!

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

In this Discussion