List page numbers & perpage control
2 posts by 2 authors in: Forums > CMS Builder
Last Post: June 23, 2008 (RSS)
By rjbathgate - June 23, 2008
Hi again,
Got a few questions I'm hoping to pick your brains for...
Question 1:
I have a list page, which has page controls (i.e. Prev / Next / You are viewing page 2 of 11) on it. Is there anyway I can have it display links to each page directly...
for example
I can't just hard code it in to the results page as sometimes there might not be 10 + pages -- for example if we only had5 results pages, links to page 6,7,8,9 and 10 would all be broken.
And ideally I would also like to be able to present an active state on the number which you are on... so somehow would need to have the CMS place a class tag onto the current page number. Is that possible?!!!
Question 2:
On the results list page, I'm trying to build a select/drop down box so user can choose how many results to display page page. In the step 1 of the page, set default is 'perPage' => '10'. Is there anyway to have the select box on change, update this, so user can for example see 20 results page page.
The results list page come as a result of a multi-option search engine, so the reloading of the results with different perPage number need to keep the search engine criteria... this is the crux...!
Question 3:
On the same results listing page as above, I also want a select/drop down where user can change the sorting order (price high/price low etc etc). I have this function working correctly on the search engine leading to the results page and the below code is on my results page:
To incorporate this same orderby select/drop down box on the actual results page, I can simply have an onchange function to reload the page with appropriate orderby tag -- however as per question 2, the other search engine criteria which has been passed over needs to remain - again, the crux!
In other words, when the page refreshes with new ordering, it needs to go through as, for example:
I hope all the makes sense, and huge thanks and appreciation for you help and advice in advice!!
Cheers,
Rob
Got a few questions I'm hoping to pick your brains for...
Question 1:
I have a list page, which has page controls (i.e. Prev / Next / You are viewing page 2 of 11) on it. Is there anyway I can have it display links to each page directly...
for example
Previous - 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - Next
I can't just hard code it in to the results page as sometimes there might not be 10 + pages -- for example if we only had5 results pages, links to page 6,7,8,9 and 10 would all be broken.
And ideally I would also like to be able to present an active state on the number which you are on... so somehow would need to have the CMS place a class tag onto the current page number. Is that possible?!!!
Question 2:
On the results list page, I'm trying to build a select/drop down box so user can choose how many results to display page page. In the step 1 of the page, set default is 'perPage' => '10'. Is there anyway to have the select box on change, update this, so user can for example see 20 results page page.
The results list page come as a result of a multi-option search engine, so the reloading of the results with different perPage number need to keep the search engine criteria... this is the crux...!
Question 3:
On the same results listing page as above, I also want a select/drop down where user can change the sorting order (price high/price low etc etc). I have this function working correctly on the search engine leading to the results page and the below code is on my results page:
$orderBy = "";
if (@$FORM['order'] == 'pricehigh') { $orderBy = "price+0 DESC"; }
if (@$FORM['order'] == 'pricelow') { $orderBy = "price+0"; }
if (@$FORM['order'] == 'alpha') { $orderBy = "title"; }
if (@$FORM['order'] == 'bedrooms') { $orderBy = "bedrooms+0";
To incorporate this same orderby select/drop down box on the actual results page, I can simply have an onchange function to reload the page with appropriate orderby tag -- however as per question 2, the other search engine criteria which has been passed over needs to remain - again, the crux!
In other words, when the page refreshes with new ordering, it needs to go through as, for example:
resultspage.php?price_min=&price_max=&bedrooms_min=&order=pricehigh&reference=&page=2
I hope all the makes sense, and huge thanks and appreciation for you help and advice in advice!!
Cheers,
Rob
Re: [rjbathgate] List page numbers & perpage control
By Dave - June 23, 2008
Hi Rob,
See this post for details on create a page number list:
http://www.interactivetools.com/iforum/P62705#62705
For the perpage you can pass that as a form value and set it like this:
For question 3, you can add extra arguments on the end of your links, for example:
<?php echo $listDetails['nextPageLink'] ?>&order=<?php echo @$FORM['order']; ?>">
Hope that helps! Let me know if you need more details on any of that. :)
See this post for details on create a page number list:
http://www.interactivetools.com/iforum/P62705#62705
For the perpage you can pass that as a form value and set it like this:
$perPage = 10;
if (@$FORM['order']) { $perPage = (int) $FORM['order']; }
...
'perPage' => $perPage,
...
For question 3, you can add extra arguments on the end of your links, for example:
<?php echo $listDetails['nextPageLink'] ?>&order=<?php echo @$FORM['order']; ?>">
Hope that helps! Let me know if you need more details on any of that. :)
Dave Edis - Senior Developer
interactivetools.com
interactivetools.com