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. |