View Single Post
  #40  
Old 08-18-2012, 05:16 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

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

I've completed this for 4.3. I couldn't find this mentioned elsewhere so hopefully this isn't redundant.

New file change_ppp.php:

PHP Code:
<?php
if (!defined('XCART_SESSION_START') && $_SERVER['REQUEST_METHOD'] != 'POST') {
    
header('Location: home.php');
    die(
'Access denied');
}

require 
'./auth.php';
x_session_register('products_per_page');

if (
$_SERVER['REQUEST_METHOD'] == 'POST' && $ppp) {

    
$back $_SERVER['HTTP_REFERER'];
    if (!
$back)
        
$back '/home.php';

    if (
$ppp == 'all')
        
$ppp 32767;

    
$products_per_page = (int)$ppp;
    
x_session_save('products_per_page');

    
func_header_location($back);
}

if ((int)
$products_per_page 0)
    
$objects_per_page $config['Appearance']['products_per_page'] = $products_per_page;

$smarty->assign('products_per_page'$config['Appearance']['products_per_page']);

$pppList = array(
    
6,12,24,48,72,120,32767
);
$smarty->assign('pppList'$pppList)
?>

New file skin1/customer/change_ppp.tpl:

PHP Code:
<form method="post" action="{$xcart_web_dir}/change_ppp.php" style="float:right">
    
Show products per page
    
<select name="ppp" onchange="this.form.submit()">
        {foreach 
from=$pppList item=pli name=pli}
            <
option value="{if $smarty.foreach.pli.last}all{else}{$pli}{/if}"{if $products_per_page eq $pliselected{/if}>{if $smarty.foreach.pli.last}all{else}{$pli}{/if}</option>
        {/foreach}
    </
select>
</
form>
<
div class="clearing"></div

Add the following to home.php just below the auth.php line:

PHP Code:
if (!empty($cat))
    include 
$xcart_dir.'/change_ppp.php'

Add the following to the very end of skin1/customer/main/navigation.tpl:

PHP Code:
{include file="customer/change_ppp.tpl"

Add the following to .nav-pages in skin1/main.css:

Code:
float: left;
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote