ModularMerchant
Knowledge Base
Shopping Cart Software Online Manual
Override the default results per page
Including additional variables in "Add to Cart" links Using PHP includes in Templates
Location Home > Developer's Guide > Code Samples

Override the default results per page

this article last updated: December 23, 2011
Due to inevitable changes that will be made to the shopping cart software over time, the cart's variable and database structure may change from time to time without advanced notice. We will attempt to keep the information in this article up-to-date, but Modular Merchant makes no guarantee as to the accuracy of the information provided in this article. Use this information at your own risk.

override like the wind
I was wondering how to change the default number of products shown on the category pages in the storefront. I would like to change the default amount shown from 25 to a different number. Is this possible?

Yes, this can be done. It requires adding a little PHP code to the beginning of the HTML template for those store page you'd like to change.

In Modular Merchant version 3, the PHP code to add looks like this:
code
<?php
if(($_SESSION[$basename]['rpp']=='25') && (!isset($_POST['rpp']))) {
     
$_SESSION[$basename]['rpp']='X';
}
?>


In MMv4, the PHP code to add looks like this:
code
<?php
if(($_SESSION[mmid()][$mm['bn']]['rpp']=='25') && (!isset($_POST['rpp']))) {
     
$_SESSION[mmid()][$mm['bn']]['rpp']='X';
     
mm_set_sql_limits();
}
?>


Whether you're working with version 3 or 4 of the shopping cart software, change X to the desired default number of results per page.

Add this code to each template that you want to override the default number of results on.

Once the number of results is changed for a store page, it will remain in affect for that page type for the duration of the customer's browsing session, unless the customer manually changes the number of results per page themselves.

example one
Using the code sample above in the store's category.tpl template file, and changing "X" to "5", would cause five products to be displayed at a time on the storefront's category pages.

Once the results per page are overridden for a category page, every other category will use the newly assigned results per page — even if the other categories use a different template, such as category_2.tpl.

However, overriding the results per page on one type of store pages won't affect the number of results per page on other types. For example, the vendor pages will still display the default 25 products per page.

To also override the number of products per page on the vendor pages, add the sample PHP code to the vendor pages' templates too.


— Last Edited - 12/23/2011 10:51am PST
Rank and add a comment to this article
Only logged in users may leave comments and rank articles. Log in to have your say!
  Knowledge Base Home

  QuickCode™ Tag Glossary

  Modular Merchant.com Homepage

Not Logged in.
Either Log in or create a User Account.

Other articles in this category...

Can I add error messages to a storefront page?

Checkbox that adds additional products to the basket

Including additional variables in "Add to Cart" links

Override the default results per page

Using PHP includes in Templates