We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Custom pagination approach

Development and Programming

mahalie's avatar
mahalie
60 posts
14 years ago
mahalie's avatar mahalie

I have built a template that parses the URI for pagination logic (template/pagesize/pagenumber) for example: http://www.site.com/search_results/25/page2 using:

//look at third URI segment for page size, default to 25 if not found
$page_size = $this->EE->uri->segment(3, 25);

//look at fourth URI segment for page number, default to 'page1' if not found
//use substring to remove 'page' from URI
$page_current = substr($this->EE->uri->segment(4, 'page1'),4);

This template is a search results page that displays the form again so you can tweak the query.

It’s simple enough to create links or select lists with page size options and to create next and previous links. The problem is when you click “next” the form is not submitted.

I’m not sure how to approach it from here. Should I store search form values in session or use jQuery to update the form action to include the path pagination logic? Or I could use hidden inputs (with jQuery) to save the pagesize and pagenumber but then I’m just spoofing the URI.

I’m a bit out of my depth here. I don’t know that this is specifically EE/CI related but perhaps there is a best practice or existing CI example/tutorial I could use for custom paging?

BTW: I’m custom paging data sets from a remote DB - not EE assets. Really, I don’t WANT to reinvent the wheel…in this case I have to.

And now that I’ve written the question out, session vars seems like the obvious answer but I would really welcome advice/input from you experienced devs!

p.s. I can post a page to redir you to secret dev site if needed, don’t want to put path in search-able forums.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.