Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

Let Customer choose number of products displayed on page

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #11  
Old 03-31-2008, 02:39 PM
 
wayfarer wayfarer is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 56
 

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

Quote:
Originally Posted by Jon
$products_per_page however could be specified from the url string with registered globals enabled. i.e. change_ppp.php?products_per_page=X

Right, Jon, you've lost me now...

(By the way, after I implemented your suggestions, I noticed that if I clicked on the ALL option, I simply received a blank page in my browser (change_ppp.php). Clicking on the other options worked fine.)
__________________
X Cart Pro
v. 4.1.9
Download Expander (from Altered Cart)
X-Magnifier
Dynamic Preview (from BCS Engineering)
Customer Rewards Points (BCSE), used as credit purchasing system
Reply With Quote
  #12  
Old 03-31-2008, 03:07 PM
 
Viejo Viejo is offline
 

Advanced Member
  
Join Date: Sep 2006
Location: San Diego area
Posts: 34
 

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

Pretty slick! I've been thinking about adding "Products Per Page" to the category modify template so the cart can be configured at the category level for page length. Don't suppose anybody's already done that?
__________________
Versions 4.3.1 - 4.5
Reply With Quote
  #13  
Old 03-31-2008, 08:09 PM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

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

I don't want to hijack this thread as it's a good mod... and not my mod... but I've had to assist several store owners who have had the misfortune of having their sites hacked due to varying exploits, so please excuse my paranoia and hesitation to rely on x-cart's data sanitizing

Here's the code I would use in change_ppp.php:

Code:
<?php if ( !defined('XCART_SESSION_START') && ($_SERVER['REQUEST_METHOD'] != "POST")) { header("Location: home.php");} require_once "auth.php"; x_session_register("products_per_page"); if ($_SERVER['REQUEST_METHOD'] == "POST") { if ($ppp) { $back = $_SERVER['HTTP_REFERER']; if (!$back) $back = "/home.php"; if ($ppp == "all") { $ppp = 32767; } else { $products_per_page = (int)$ppp; } x_session_save("products_per_page"); func_header_location($back); } } if ((int)$products_per_page > 0) { $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"]); ?>
Reply With Quote

The following user thanks Jon for this useful post:
clik (04-23-2009)
  #14  
Old 03-31-2008, 08:32 PM
 
wayfarer wayfarer is offline
 

Advanced Member
  
Join Date: Apr 2003
Posts: 56
 

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

I appreciate that thanks Jon that code seems to work fine, including the show ALL...
__________________
X Cart Pro
v. 4.1.9
Download Expander (from Altered Cart)
X-Magnifier
Dynamic Preview (from BCS Engineering)
Customer Rewards Points (BCSE), used as credit purchasing system
Reply With Quote
  #15  
Old 04-01-2008, 01:05 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

Thank you, Jon, for this corrections. Of course, somebody could read this thread and use opened code to find a security hole. Anyway thanks Jon.
__________________
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
  #16  
Old 04-22-2008, 04:35 AM
 
masculinefires masculinefires is offline
 

Member
  
Join Date: Jun 2004
Posts: 25
 

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

Has anyone encountered problems with this working in HTML Catalog mode? Can't seem to make it work there, only in dynamic mode
__________________
X-Cart 4.1.9
PHP 4.3.10
MYSQL 3.23.58
Apache/2.0.51 (Fedora)
Linux
Perl 5.008003
Reply With Quote
  #17  
Old 06-09-2008, 07:28 PM
 
pdubya1632 pdubya1632 is offline
 

Newbie
  
Join Date: Jun 2007
Posts: 1
 

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

Excellent post and exactly something I needed...except for one thing -> the onchange in the form provided in post #2 gave this error: "document.product_per_page_form has no properties"

So instead of
onchange="javascript: document.product_per_page_form.submit();"
I used
onchange="this.form.submit()"
which fixes the problem

I then stripped out the unnecessary name attribute in the form tag and the all option (since that would have been overkill for me), and added an id so I could apply styles:

Code:
<form method="POST" action="/change_ppp.php" id="pppForm"> Show products per page <select name="ppp" onchange="this.form.submit()"> <option value="12" {if $products_per_page eq 10}selected{/if}>12</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> </select> </form>

I successfully tested it in PC Firefox & IE7, Mac Firefox & Safari. You can see it in action here: http://www.shopbettylin.com/home.php?cat=249
__________________
X-Cart Gold
Version 4.1.9

--wrightmight.com--
Reply With Quote
  #18  
Old 06-10-2008, 12:12 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 right about this modification.
__________________
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
  #19  
Old 06-12-2008, 03:38 PM
 
Thedae2k Thedae2k is offline
 

eXpert
  
Join Date: Jan 2004
Posts: 288
 

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

Works great...thanks for the great contribution Antony and I appreciate the concern for security Jon.
__________________
X-Cart Pro 4.1.9
PHP5.2.5
MySQL 5.0.54
IIS/Apache/NGINX Webservers
Reply With Quote
  #20  
Old 11-12-2008, 03:39 PM
 
Jerrad Jerrad is offline
 

X-Adept
  
Join Date: Nov 2004
Location: The Netherlands
Posts: 484
 

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

Very useful mod, but I guess it's only for 4.1.x and not for 4.0.x?
Because changing the number of products brings me straight away to home.php...

Anybody a idea what to change so it will also work with 4.0.x?
I really could use this mod in our store...

Thanks!
__________________
X-Cart 4.0.12
Heavy modified with paid, free and forum mods.
PHP 5.2.5 | MYSQL 5.0.51a
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:22 PM.

   

 
X-Cart forums © 2001-2020