Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2004
    Posts
    104
    Plugin Contributions
    0

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

    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.

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

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

    Here's the concepts:

    1. You'll need to combine components from /includes/modules/product_listing.php
    Code:
    $listing_split = new splitPageResults($listing_sql, MAX_DISPLAY_PRODUCTS_LISTING, 'p.products_id', 'page');
    (substituting $categories_query for $listing_sql, since $listing_sql is the SQL query that determines the data to be pulled from the database

    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:
    Code:
    <?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
    Code:
       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.

  3. #3
    Join Date
    Dec 2004
    Posts
    104
    Plugin Contributions
    0

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

    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?

 

 

Similar Threads

  1. Limit the number of accounts per IP address?
    By TJR Stores in forum General Questions
    Replies: 2
    Last Post: 28 Aug 2009, 07:01 AM
  2. How to limit the number of countries from the shipping estimator page?
    By w00gle in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 9 Jun 2009, 03:58 PM
  3. Listing X number of subcategories per page
    By frostbite7217 in forum Setting Up Categories, Products, Attributes
    Replies: 0
    Last Post: 17 Sep 2007, 08:16 PM
  4. I think qhome has modules figured out! So, what about some guidelines?
    By kelvyn in forum Contribution-Writing Guidelines
    Replies: 1
    Last Post: 8 Sep 2006, 11:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg