X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Let Customer choose number of products displayed on page (https://forum.x-cart.com/showthread.php?t=38695)

wayfarer 03-31-2008 02:39 PM

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

Viejo 03-31-2008 03:07 PM

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?

Jon 03-31-2008 08:09 PM

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"]);
?>


wayfarer 03-31-2008 08:32 PM

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

Holub 04-01-2008 01:05 AM

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.

masculinefires 04-22-2008 04:35 AM

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

pdubya1632 06-09-2008 07:28 PM

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

Holub 06-10-2008 12:12 AM

Re: Let Customer choose number of products displayed on page
 
Yes, you right about this modification.

Thedae2k 06-12-2008 03:38 PM

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.

Jerrad 11-12-2008 03:39 PM

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! :-):-):-)


All times are GMT -8. The time now is 03:09 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.