View Single Post
  #2  
Old 03-30-2008, 03:58 AM
  Holub's Avatar 
Holub Holub is offline
 

X-Adept
  
Join Date: Jan 2008
Posts: 432
 

Default Re: Let Customer choose number of products displayed on page

Yes, you can do it.

First of all you should create file in root dir called "change_ppp.php" with this code:

File "change_ppp.php":
Code:
<?php if ( !defined('XCART_SESSION_START') && ($REQUEST_METHOD != "POST")) { header("Location: home.php");} require_once "auth.php"; x_session_register("products_per_page"); if ($REQUEST_METHOD=="POST") if ($ppp) { $back = $_SERVER['HTTP_REFERER']; if (!$back) $back = "/home.php"; if ($ppp == "all") $ppp = 32767; $products_per_page = $ppp; x_session_save("products_per_page"); func_header_location($back); } if ($products_per_page) { $config["Appearance"]["products_per_page"] = $products_per_page; $objects_per_page = $config["Appearance"]["products_per_page"]; } $smarty -> assign("products_per_page",$config["Appearance"]["products_per_page"]); ?>

Next step:

include into "auth.php" before end of file (?>)

Code:
include "change_ppp.php";

Next step:

include into /skin1/customer/main/products.tpl

Code:
<form method="POST" action="/change_ppp.php" name="product_per_page_form"> Show products per page <select name="ppp" onchange="javascript: document.product_per_page_form.submit();"> <option value="5" {if $products_per_page eq 5}selected{/if}>5</option> <option value="10" {if $products_per_page eq 10}selected{/if}>10</option> <option value="20" {if $products_per_page eq 20}selected{/if}>20</option> <option value="30" {if $products_per_page eq 30}selected{/if}>30</option> <option value="50" {if $products_per_page eq 50}selected{/if}>50</option> <option value="75" {if $products_per_page eq 75}selected{/if}>75</option> <option value="100" {if $products_per_page eq 100}selected{/if}>100</option> <option value="all" {if $products_per_page eq 32767}selected{/if}>all</option> </select> </form>

after

Code:
{* $Id: products.tpl,v 1.72.2.3 2006/11/27 11:40:25 max Exp $ *} {if $active_modules.Feature_Comparison ne '' && $products && $printable ne 'Y' && $products_has_fclasses} {include file="modules/Feature_Comparison/compare_selected_button.tpl"} {include file="modules/Feature_Comparison/products_check_js.tpl"} {/if}

This modification allows customer to select products per page and selected value will stored in session variable.

You can change this code as you want. I've checked this code and sure he works correctly.
__________________
Regards,
Anthony Holub

X-Cart Skins Store
- twenty two different skins available;
- both 4.1.x and 4.2.x versions compatible;
- refresh you store now!

Smart menu X-Cart add-on
Featured Products Slide Show X-Cart add-on
"What's New?" FREE X-Cart add-on
Reply With Quote