Zen Cart Logo
If this is your first visit, check our documentation. To post, register or login.
Forums / Setting Up Your Zen Cart Products / Setting Up Categories, Products, Attributes / Has anyone ever figured out how to limit the number of subcategories per page.

Has anyone ever figured out how to limit the number of subcategories per page.

Locked

Started by member on 24 Jun 2008, 6:18 PM · Views: 1,351

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
24 Jun 2008, 6:18 PM
#1
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Post #1 by member

Has anyone ever figured out how to limit the number of subcategories per page.

It is not part of the design of Zen cart from everything I can find.

I found this thread http://www.zen-cart.com/forum/showthread.php?t=63780 where post # 7 said the following:

Yes, we did figure it out. Basically copy and pasted the prev/next code from the admin's version of that page to the sub-categories.

I tried to contact them for a better explaination, but my emails went unanswered.

Can anyone decipher what that statement might have been refering to?

I have categories with the subcategories being products (for example item number 1). I then have products in the subcategory for each color.

I could have used the attributes for each product, but I did not. At first because I could not keep track of inventory. I see now that there is a stock by attributes contribution, but I have spent too much time setting things up the way they are. I did try playing with the attribute option and found that the search will not search the attributes anyway, so it would not be the best option for my site.

I just need to know how to get a next page for my subcategories so I can show 20 or so per page. If I put everything in the subcategory that it belongs in I would end up having a page that might not load for dial up users.

Thanks for any suggestions.

25 Jun 2008, 4:48 AM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,512
Plugin Contributions:
176

Post #2 by drbyte

Here's the concepts:

  1. You'll need to combine components from /includes/modules/product_listing.php```
    $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');

MAX_DISPLAY_PRODUCTS_LISTING is the number of records per page, as defined in the admin .... you will probably just end up hard-coding the number of desired records per page, rather than creating a new admin switch)

... combining that kind of selection code into /includes/modules/category_row.php
 ... keeping in mind that there is logic in that file for combining several subcats on a given row. Thus, you may have to accommodate the number of items per-row when calculating number of rows per page.



2. You'll need to take template-related display components from something like this in tpl_modules_product_listing.php:```
<?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '3') ) ) {
?>
<div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_PRODUCTS); ?></div>
<div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div>
<br class="clearBoth" />
<?php
}
?>

and add it around something like this in the tpl_index_categories.php file

   require($template->get_template_dir('tpl_modules_category_row.php',DIR_WS_TEMPLATE, $current_page_base,'templates'). '/tpl_modules_category_row.php');

You'll find the split_page_results logic used in various places on the storefront, and quite extensively in the admin, in case you need more examples of it in action.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

25 Jun 2008, 8:30 PM
#3
member avatar

member

Zen Follower

Join Date:
Dec 2004
Posts:
102
Plugin Contributions:
0

Post #3 by member

I can't thank you enough for helping me with this.

I did what you said (I think). I added

$listing_split = new splitPageResults($categories_query, MAX_DISPLAY_PRODUCTS_LISTING, '1', 'page');

to category_row.php

AND

<?php if ( ($listing_split->number_of_rows > 0) && ( (PREV_NEXT_BAR_LOCATION == '1') || (PREV_NEXT_BAR_LOCATION == '2')|| (PREV_NEXT_BAR_LOCATION == '3') ) ) { ?><br> <div id="productsListingTopNumber" class="navSplitPagesResult back"><?php echo $listing_split->display_count(TEXT_DISPLAY_NUMBER_OF_CATEGORIES); ?></div> <div id="productsListingListingTopLinks" class="navSplitPagesLinks forward"><?php echo TEXT_RESULT_PAGE . ' ' . $listing_split->display_links(MAX_DISPLAY_PAGE_LINKS, zen_get_all_get_params(array('page', 'info', 'x', 'y', 'main_page'))); ?></div> <br class="clearBoth" /> <?php } ?>

to tpl_index_categories.php

I did add || (PREV_NEXT_BAR_LOCATION == '2') because I wanted to display it on the bottom only.

I also am using MAX_DISPLAY_PRODUCTS_LISTING, '1' because I am trying to limit the display (while testing) and I
was not sure if I used 6 for example if I would get 6 sub categories or 18.

I am using column grid layout - 3 per row.

I see at the bottom Displaying 1 to 11 (of 11 products).

I am still doing something wrong because with the above example, I would expect to get either 1 or 3 subcategories. Is there something in the admin that I need to change?

I am thinking somewhere between 12 and 20 subcategories per page would be about right. That would be 4 to 7 rows.

Sorry to bother you again, I really wanted to get it figured out without bothering you more.

Do you have any idea what I might be missing?