Forums / Setting Up Categories, Products, Attributes / Number of Products per page...

Number of Products per page...

Views: 23,950

Results 1 to 20 of 31
6 Jun 2006, 10:21 AM
#1
dandownunder avatar

dandownunder

Zen Follower

Join Date:
Jan 2006
Location:
Portugal
Posts:
347
Plugin Contributions:
0

Number of Products per page...

Hi Guys, I am trying to work out how to change the number of products displayed per page ? I know it is in Configuration >Maximum Values but which one is it that needs to be changed, I need it to display only 6 products per page.
Any help would be great

Cheers
Dan.

2 Feb 2009, 3:05 AM
#2
spindletosashes avatar

spindletosashes

New Zenner

Join Date:
Feb 2009
Posts:
2
Plugin Contributions:
0

Re: Number of Products per page...

It's in admin/config/max values/ PRODUCT LISTING-NUMBER PER PAGE.

change that number to whatever you want. If you want all of your products in that category to show, simply type an insanely high number. :D

Baby Products and sewing patterns Spindle To Sashes

23 May 2009, 6:38 PM
#3
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Number of Products per page...

Does anyone know how to modify ZC so that the customer can choose from a list, how many products per page to display? Or at least give them the option to click "show all" ?

I have my All Products page set to display 32 products per page, but I'd like the customer to have different options.

23 May 2009, 7:25 PM
#4
bobdog avatar

bobdog

Totally Zenned

Join Date:
Mar 2006
Location:
Fresno, California
Posts:
590
Plugin Contributions:
0

Re: Number of Products per page...

Hi limelites,

There is a way to view all in a category. I did this about a year ago...

http://www.zen-cart.com/forum/showthread.php?t=38551&page=3

see post #24 by modernm

it involves editing product_listing.php and tpl_modules_product_listing.php

it will give you a [view all] link in categories

24 May 2009, 10:55 AM
#5
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Number of Products per page...

Thanks BobDog, that's a very useful link! I'm looking more at post 27 though as it seems this is the best working mod for all pages.

My trouble is that I already have a modified split_page_results.php which is giving me my drop down page numbers.

I'm having a hard time merging my own file with the file in post 27.

My file with the drop down mods:
http://www.limelites.co.uk/includes/classes/split_page_results.rar

This new file which gives a view all option:
http://www.limelites.co.uk/includes/classes/split_page_results.php.view_all.rar

Can't get them to merge :-(

27 May 2009, 1:32 AM
#6
pelasgos avatar

pelasgos

New Zenner

Join Date:
Dec 2006
Location:
Athens - Greece
Posts:
71
Plugin Contributions:
0

Re: Number of Products per page...

limelites:

Thanks BobDog, that's a very useful link! I'm looking more at post 27 though as it seems this is the best working mod for all pages.

My trouble is that I already have a modified split_page_results.php which is giving me my drop down page numbers.

I'm having a hard time merging my own file with the file in post 27.

My file with the drop down mods:
http://www.limelites.co.uk/includes/classes/split_page_results.rar

This new file which gives a view all option:
http://www.limelites.co.uk/includes/classes/split_page_results.php.view_all.rar

Can't get them to merge :-(

Thanks limelites!
Your drop-down mod works great!
:clap:

27 May 2009, 7:46 AM
#7
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Number of Products per page...

You're welcome.

Oh and by the way, for anyone interested, the merged version which gives both the drop down for page numbers AND the choice to choose how many products per page (in my case 100, 200, 300, 400, View All) here is the split page file for /includes/classes:

http://www.limelites.co.uk/split_page_results.rar

You'll also need the define file added to /includes/languages/english/extra_definitions:

http://www.limelites.co.uk/alternative_page_numbers.rar

View it in action first at http://www.limelites.co.uk/index.php?main_page=products_all

7 May 2010, 4:28 PM
#8
salixia avatar

salixia

New Zenner

Join Date:
Oct 2009
Posts:
30
Plugin Contributions:
0

Re: Number of Products per page...

limelites:

My file with the drop down mods:
http://www.limelites.co.uk/includes/classes/split_page_results.rar

This mod is great but it's giving me problems.
The drop down select for what page to jump too only works for the bottom "productsListingBottomNumber" page select under the product listing. The "productsListingTopNumber" page select drop down before the product listing does not work.

The Prev and Next buttons work on top and bottom fine.
Problem is only the top drop down for which page to jump too.
When you select a different page it stays on the same page.

A great mod that would be super for my site because we have very large categories. Sadly I dont know enough php to spot the problem.
I am using 1.3.9b. w/ no conflicting addons (already checked).
php 4.4.7

Thank you for any help!

Here is Limelites code:

<?php
/**
 * split_page_results Class.
 *
 * @package classes
 * @copyright Copyright 2003-2006 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: split_page_results.php 3041 2006-02-15 21:56:45Z wilt $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
/**
 * Split Page Result Class
 * 
 * An sql paging class, that allows for sql reslt to be shown over a number of pages using  simple navigation system
 * Overhaul scheduled for subsequent release
 *
 * @package classes
 */
class splitPageResults extends base {
  var $sql_query, $number_of_rows, $current_page_number, $number_of_pages, $number_of_rows_per_page, $page_name;

  /* class constructor */
  function splitPageResults($query, $max_rows, $count_key = '*', $page_holder = 'page', $debug = false) {
    global $db;

    $this->sql_query = $query;
    $this->page_name = $page_holder;

    if ($debug) {
      echo 'original_query=' . $query . '<br /><br />';
    }
    if (isset($_GET[$page_holder])) {
      $page = $_GET[$page_holder];
    } elseif (isset($_POST[$page_holder])) {
      $page = $_POST[$page_holder];
    } else {
      $page = '';
    }

    if (empty($page) || !is_numeric($page)) $page = 1;
    $this->current_page_number = $page;

    $this->number_of_rows_per_page = $max_rows;

    $pos_to = strlen($this->sql_query);

    $query_lower = strtolower($this->sql_query);
    $pos_from = strpos($query_lower, ' from', 0);

    $pos_group_by = strpos($query_lower, ' group by', $pos_from);
    if (($pos_group_by < $pos_to) && ($pos_group_by != false)) $pos_to = $pos_group_by;

    $pos_having = strpos($query_lower, ' having', $pos_from);
    if (($pos_having < $pos_to) && ($pos_having != false)) $pos_to = $pos_having;

    $pos_order_by = strpos($query_lower, ' order by', $pos_from);
    if (($pos_order_by < $pos_to) && ($pos_order_by != false)) $pos_to = $pos_order_by;

    if (strpos($query_lower, 'distinct') || strpos($query_lower, 'group by')) {
      $count_string = 'distinct ' . zen_db_input($count_key);
    } else {
      $count_string = zen_db_input($count_key);
    }
    $count_query = "select count(" . $count_string . ") as total " .
    substr($this->sql_query, $pos_from, ($pos_to - $pos_from));
    if ($debug) {
      echo 'count_query=' . $count_query . '<br /><br />';
    }
    $count = $db->Execute($count_query);

    $this->number_of_rows = $count->fields['total'];

    $this->number_of_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page);

    if ($this->current_page_number > $this->number_of_pages) {
      $this->current_page_number = $this->number_of_pages;
    }

    $offset = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

    // fix offset error on some versions
    if ($offset < 0) { $offset = 0; }

    $this->sql_query .= " limit " . $offset . ", " . $this->number_of_rows_per_page;
  }

  /* class functions */

  function display_links($max_page_links,$parameters = '') {
      if ( zen_not_null($parameters) && (substr($parameters, -1) != '&') ) $parameters .= '&';
      $num_pages = ceil($this->number_of_rows / $this->number_of_rows_per_page);
      $pages_array = array();
      for ($i=1; $i<=$num_pages; $i++) {
        $pages_array[] = array('id' => $i, 'text' => $i);
      }

      if ($num_pages > 1) {
        $display_links = zen_draw_form('pages', zen_href_link($_GET['main_page']),'get') . zen_draw_hidden_field('main_page', $_GET['main_page']);

        if ($this->current_page_number > 1) {
          $display_links .= '<a href="' . zen_href_link($_GET['main_page'], $parameters . $this->page_name . '=' . ($this->current_page_number - 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_PREV . '</a>  ';
        } else {
          $display_links .= PREVNEXT_BUTTON_PREV . '  ';
        }

    $display_links .= sprintf('Page %s of  %d', zen_draw_pull_down_menu($this->page_name, $pages_array, $this->current_page_number, 'onChange="this.form.submit();"'), $num_pages);

        if (($this->current_page_number < $num_pages) && ($num_pages != 1)) {
          $display_links .= '  <a href="' . zen_href_link($_GET['main_page'], $parameters . $this->page_name . '=' . ($this->current_page_number + 1), 'NONSSL') . '" class="splitPageLink">' . PREVNEXT_BUTTON_NEXT . '</a>';
        } else {
          $display_links .= '  ' . PREVNEXT_BUTTON_NEXT;
        }

        if ($parameters != '') {
          if (substr($parameters, -1) == '&') $parameters = substr($parameters, 0, -1);
          $pairs = explode('&', $parameters);
          while (list(, $pair) = each($pairs)) {
            list($key,$value) = explode('=', $pair);
            $display_links .= zen_draw_hidden_field(rawurldecode($key), rawurldecode($value));
          }
        }

        if (SID) $display_links .= zen_draw_hidden_field(zen_session_name(), zen_session_id());

        $display_links .= '</form>';
      } else {
        $display_links = sprintf(TEXT_RESULT_PAGE, $num_pages, $num_pages);
      }
      return $display_links;
    }  
  // display number of total products found
  function display_count($text_output) {
    $to_num = ($this->number_of_rows_per_page * $this->current_page_number);
    if ($to_num > $this->number_of_rows) $to_num = $this->number_of_rows;

    $from_num = ($this->number_of_rows_per_page * ($this->current_page_number - 1));

    if ($to_num == 0) {
      $from_num = 0;
    } else {
      $from_num++;
    }

    if ($to_num <= 1) {
      // don't show count when 1
      return '';
    } else {
      return sprintf($text_output, $from_num, $to_num, $this->number_of_rows);
    }
  }
}
?>
7 May 2010, 5:27 PM
#9
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Number of Products per page...

Can you post a link to your site please?

7 May 2010, 5:41 PM
#10
salixia avatar

salixia

New Zenner

Join Date:
Oct 2009
Posts:
30
Plugin Contributions:
0

Re: Number of Products per page...

:O Limelites just the person I was hoping to respond! Thanks.

My test server:
http://www.bearfreak.com/index.php?main_page=index&cPath=1_92_94&sort=20a

You wouldn't also be able to tell me how you were able to get Filter Results by: price, date added ect. on all product listings?

7 May 2010, 6:19 PM
#11
limelites avatar

limelites

Totally Zenned

Join Date:
Jan 2009
Posts:
2,085
Plugin Contributions:
0

Re: Number of Products per page...

I think it mentions in this thread near the beginning that this mod will not work with sites which have the add to cart function on the listing pages. It only works on sites that have the 'more info' link replacing the add to cart function.

To make this work with your site would require some custom coding work.

As for the filter system, look on Google. I can't find the exact mod I used, but I remember I found it on an obscure site some where, not in the downloads area.

Sorry I can't be more help, busy building another two sites......

https://www.superfancy.co.uk and https://www.silkblooms.co.uk

7 May 2010, 6:45 PM
#13
salixia avatar

salixia

New Zenner

Join Date:
Oct 2009
Posts:
30
Plugin Contributions:
0

Re: Number of Products per page...

Sure enough I turned off the add to cart buttons and it worked.

That is odd that with those buttons on the bottom drop down works fine but not the top. Thanks for the tip, I'll see if I can fix this myself now that I know where too look.

Also thanks for the filter link. I will try that.

7 May 2010, 7:25 PM
#14
salixia avatar

salixia

New Zenner

Join Date:
Oct 2009
Posts:
30
Plugin Contributions:
0

Re: Number of Products per page...

Filter mod worked perfectly thanks! Which is great because our store sells thousands of coins and its so much easier for customers if they can filter by price.

I'll keep working on the other mod.

21 Sep 2010, 3:47 PM
#15
jabbawest avatar

jabbawest

Zen Follower

Join Date:
Oct 2009
Location:
Texas
Posts:
197
Plugin Contributions:
0

Re: Number of Products per page...

Quite happily, I stumbled upon this thread and easily implemented the ProductFilter2 mod, however...
I'm hoping someone has discovered a work around for this but yet again, I've run into the filter by price problem I always have with additions like this one.
I have several products that are priced by attributes and unfortunately, this mod doesn't, and may not be able to, take that into account.
http://minu.me/304v
Now choose filter by Price Low to High.

The first two items are seen by PF2 as $0.00 priced because they are priced by their carat sizes.

I've also tried the product_filter_by_attribute_and_price_range_0-7 mod with no luck because it wouldn't filter by a price based attribute.

Fine Jewelry For Any Budget
Sterling Leaf Jewelry
Rolling in the Zen

30 Sep 2010, 9:12 PM
#16
fontaholic avatar

fontaholic

Zen Follower

Join Date:
Jun 2008
Posts:
111
Plugin Contributions:
0

Re: Number of Products per page...

limelites:

You're welcome.

Oh and by the way, for anyone interested, the merged version which gives both the drop down for page numbers AND the choice to choose how many products per page (in my case 100, 200, 300, 400, View All) here is the split page file for /includes/classes:

http://www.limelites.co.uk/split_page_results.rar

You'll also need the define file added to /includes/languages/english/extra_definitions:

http://www.limelites.co.uk/alternative_page_numbers.rar

View it in action first at http://www.limelites.co.uk/index.php?main_page=products_all

hi, i'm still a noob with php files and i've spent hours trying to un-do things i've messed up, so i'm just going to go ahead and ask....

i have installed these two bits, but am not seeing how to define the increments of the products per page and display it as a drop down box? what are the css styles/ids/etc i need to change to alter their appearance?

sorry to seem dense. my site is at http://store.inspiritcommon.com/ there's a password to access the site since it's not ready for prime time. un: alphatester pw:Gr8gratitude.

thanks!

:) emily
http://store.inspiritcommon.com/
ZC 1.3.8a on Godaddy :: EP 1.2.5.4 :: Adv Search 1.1 and a buncha other stuff

5 Oct 2010, 9:30 PM
#17
fontaholic avatar

fontaholic

Zen Follower

Join Date:
Jun 2008
Posts:
111
Plugin Contributions:
0

Re: Number of Products per page...

hooray! i figured out how to change the per-page choices, but still cannot figure out what needs to change so it displays as a dropdown. :frusty:

also figured out that i can add the class perPage to my stylesheet and control text display, but i can't seem to assign it a margin, or background so there must be a governing class that i'm missing.

also, i'd love some clarification on this:```
// perPage contains the number of items to list per page. 0 is used to indicate ALL

    if (isset($_GET['perPage'])) {
        $max_rows = (int) $_GET['perPage'];
        if ($max_rows < 0 or $max_rows >= 5000) {
            $max_rows=MAX_DISPLAY_PRODUCTS_LISTING;
            //This can be found in admin - config - maximum values.
        } elseif ($max_rows==0) {
            $max_rows=5000;
            //0 indicates ALL selected. So we use 5000 as a maximum
        }

does this mean that by default the user sees all items in the category? if i changed it to ```
            if ($max_rows < 9 or $max_rows >= 5000) {
``` would the user initially see 9 items per page? i couldn't get it to work like that but had already set it to remember the count across categories, so i'm not sure if that is affecting it.

:) emily
http://store.inspiritcommon.com/
ZC 1.3.8a on Godaddy :: EP 1.2.5.4 :: Adv Search 1.1 and a buncha other stuff

21 Oct 2010, 9:15 PM
#18
aozhaver avatar

aozhaver

Zen Follower

Join Date:
Sep 2010
Posts:
121
Plugin Contributions:
0

Re: Number of Products per page...

Hi!

You're not a noob, you're just like most of us here NOT a programmer :P

Firstly I'm glad you got that number per page choices all figured out but would you care to share how :huh:

Ive loaded the two files and I get the dropdown menu for page selection and the previous/next page links ok but mysteriously no selection appears at all for number of products per page as is on limelites website.

Perhaps I'm missing a file I just uploaded these 2:

here is the split page file for /includes/classes:

http://www.limelites.co.uk/split_page_results.rar

You'll also need the define file added to /includes/languages/english/extra_definitions:

http://www.limelites.co.uk/alternative_page_numbers.rar

What is that code that you quoted, what's the file name you're editing. I checked on the tool kit I dont seem to have such a file, perhaps thats the one I'm missing.

I also saw your posts on the product filter by attributes post, I got all that to work if you got any issues still let me know.

Cheers!:bigups:

P.S. why spend hours undoing mistakes wouldn't it be simpler to back up a file before messing with it :-)

Silver Jewellery

RESPECT to the Zen Cart Team, I'm PERFECTLY Zenned!

22 Oct 2010, 9:55 AM
#19
aozhaver avatar

aozhaver

Zen Follower

Join Date:
Sep 2010
Posts:
121
Plugin Contributions:
0

Re: Number of Products per page...

Hey Zenners!

You might find my post here somewhat useful

http://www.zen-cart.com/forum/showthread.php?t=38551&page=4

Either way I copied limelite's 2 files to the proper places and I cant get the "select number of products to display" option to show. I disabled the add to cart button but it makes no difference.

Any ideas what I might be missing, please see on https://www.majesticsilver.co.uk
Thanks!!!:smile:

Silver Jewellery

RESPECT to the Zen Cart Team, I'm PERFECTLY Zenned!

30 Jan 2011, 1:21 AM
#20
axxess avatar

axxess

New Zenner

Join Date:
Dec 2009
Posts:
19
Plugin Contributions:
0

Re: Number of Products per page...

When a product doesn't have attributes the add to cart function comes up on the listing page instead of the more info. Is there a code to make it replace with more info without going in and changing the product quantity box to not show. If I can tackle this code the number of products per page would work perfectly. Hopefully, this thread gets attention because I don't want to post a new thread for this question.

Anyone that can help, it would be greatly appreciated.