Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Pagination problem
  • I've ran into a problem using the pagination class. Lets say I have a controller photos with method current the uri would be 'photos/current/'
    public function action_current($sort = 1, $page = 1, $filter = null){
    
        $config = array(
                'pagination_url' => "photos/current/$sort/
                'total_items' => 50
                'per_page' => 10,
                'uri_segment' => 4,
            );
    //do some stuff
    }
    

    that works all good but then if i try to introduce new variables in the pagination url things get weird for example even if i define the uri_segment as 4 if i put something there like
       'pagination_url' => "photos/current/$sort/$page/blah/blah"
    

    it wont replace the 4th part of the query, it just tacks on the next page to the end. which would output something like
     photos/current/1/1/blah/blah/2
    

    I would want it to actually be
    photos/current/1/2/blah/blah
    

    Does the page always have tome come last or something?
  • The Pagination class doesn't do anything intelligent when constructing the URL's. If you want the page to be segment 4, you need to make sure that 'pagination_url' contains 3 segments. It just sticks it on. I store selections/filters and sort order in the users session. It keeps URLs clean, and it also has the advantage that the last selection is remembered when the user revisits the page.
  • Harro Verton wrote on Thursday 22nd of September 2011:
    The Pagination class doesn't do anything intelligent when constructing the URL's. If you want the page to be segment 4, you need to make sure that 'pagination_url' contains 3 segments. It just sticks it on. I store selections/filters and sort order in the users session. It keeps URLs clean, and it also has the advantage that the last selection is remembered when the user revisits the page.

    Thats probably the best way to go about it.

Howdy, Stranger!

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

In this Discussion