Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Mar 2011
    Posts
    27
    Plugin Contributions
    0

    Default Pre-select a subcategory

    Hi all Zenners,

    I have a top level category that hold no product, it only hold other categories. I'm trying to select the top subcategory when a user clicks on this top level category. Is there any option already built-in? or do I need to intercept the execution in the code and manipulate it in there? For example in this screenshot, I want to select the most recently added (Jan 14 2011) subcategory when the user click on Promotions category. Please help. Thank you.


  2. #2
    Join Date
    Mar 2011
    Posts
    27
    Plugin Contributions
    0

    Default Re: Pre-select a subcategory

    Update:

    After reading thru the code I figured out where I can intercept the code and modified it to best suits my needs. In case anyone interested.

    the file is includes/templates/MY TEMPLATE/sideboxes/tpl_categories.php around line 35

    if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == 3 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
    // skip if this is for the document box (==3)
    } else {
    /////////////////////////////1.1/////////////////////////
    if($box_categories_array[$i]['has_sub_cat'] && $new_style == 'category-top' ){

    if($ul_close=='NO'){
    $content =$content.'</ul></li>';
    $ul_close='YES';
    }
    $ul_close='NO';
    if ($box_categories_array[$i]['name'] == '* PROMOTIONS *')
    {
    $sub = get_latest_child();
    $content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '_' . $sub . '">';
    }
    else
    {
    $content .= '<li><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    }
    $content .= $box_categories_array[$i]['name'];

    $content =$content.'</a><ul>';
    }


    function get_latest_child()
    {
    global $db;
    $sql = 'Select * from zen_categories where parent_id = 5 order by sort_order limit 1';
    $result = $db->Execute($sql);
    return $result->fields['categories_id'];

    }

  3. #3
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Pre-select a subcategory

    In the Configuration ... Layout Settings ... you can configure it to Always Open to a specific Category on your Home page:
    Categories - Always Open to Show SubCategories
    Always Show Categories and SubCategories
    0= off, just show Top Categories
    1= on, Always show Categories and SubCategories when selected
    Then set the Category with the cPath for:
    Main Page - Opens with Category
    0= Top Level Categories
    Or enter the Category ID#
    Note: Sub Categories can also be used Example: 3_10
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  4. #4
    Join Date
    Mar 2011
    Posts
    27
    Plugin Contributions
    0

    Default Re: Pre-select a subcategory

    Quote Originally Posted by Ajeh View Post
    In the Configuration ... Layout Settings ... you can configure it to Always Open to a specific Category on your Home page:


    Then set the Category with the cPath for:
    Ajeh,

    Thanks for your help. That would works, but because the subcategory id is dynamically changed via an importing script that would make the cPath id becomes old. Also that would mean that the homepage would be populated with produts found in this subcategory right? if that's the case then it won't work because I only want to show the products when the user click on PROMOTIONS.

    However, this approach is much better if you can show me how to programatically change the cPath to subcategory when my script adds a new subcategory. Thanks.

  5. #5
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: Pre-select a subcategory

    What if you used the PROMOTIONS Category and then the user can pick what ever Categories are in it?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Pre-select a subcategory

    The very unusual functionality of showing the latest-added subcategory of one particular top category when that is clicked can really only be done by the type of custom coding you posted above.

    Others should note that the OP started from a custom mod version of tpl_categories.php, and a stock version of the file will look very different.

  7. #7
    Join Date
    Mar 2011
    Posts
    27
    Plugin Contributions
    0

    Default Re: Pre-select a subcategory

    Quote Originally Posted by Ajeh View Post
    What if you used the PROMOTIONS Category and then the user can pick what ever Categories are in it?
    Yes this is how the default works, it would list all subcats and the user can click on the subcats themselves, but because the subcats listing is too small, and I chose to use date as the title, at first look it looks like an error, so I choose to populate the page with the latest deals added to the database.
    the modified code worked as intended. Thanks for your help.

  8. #8
    Join Date
    Mar 2011
    Posts
    27
    Plugin Contributions
    0

    Default Re: Pre-select a subcategory

    Quote Originally Posted by gjh42 View Post
    The very unusual functionality of showing the latest-added subcategory of one particular top category when that is clicked can really only be done by the type of custom coding you posted above.

    Others should note that the OP started from a custom mod version of tpl_categories.php, and a stock version of the file will look very different.
    Thanks for the clarification and comments.

  9. #9
    Join Date
    Mar 2011
    Posts
    27
    Plugin Contributions
    0

    Default Re: Pre-select a subcategory

    Hi again,

    The code above works most of the time, but when I clear cookie the link becomes like this
    index.php?main_page=index&cPath=5&zenid=a9a6d04fcbf670a151bce972f8e9bb99_19

    Instead of something like this
    index.php?main_page=index&cPath=5_15

    What is the zenid parameter for? it seems that some other part of the code generates that link and put it underneath the PROMOTION category. Any pointer is appreciated.

  10. #10
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Pre-select a subcategory

    Zenid is the session id which keeps track of the individual customer's settings, cart contents, etc. It has to appear on the first page visit, but if cookies are enabled, it is thereafter passed by cookie and not in the URL.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v150 Pre Select Attributes With Parameter in URL
    By ShopVille in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 3 Feb 2015, 10:31 PM
  2. v150 Pre-Select A Payment Option at check-out
    By ShopVille in forum Addon Payment Modules
    Replies: 9
    Last Post: 12 Sep 2014, 03:35 PM
  3. Pre-select a shipping method?
    By Gem in forum Built-in Shipping and Payment Modules
    Replies: 11
    Last Post: 3 Mar 2008, 06:35 PM
  4. Pre-Select A Payment Option at check-out?
    By JaxMac in forum Built-in Shipping and Payment Modules
    Replies: 23
    Last Post: 1 Oct 2007, 02:04 PM
  5. Pre-select default payment method
    By breadfan in forum Built-in Shipping and Payment Modules
    Replies: 1
    Last Post: 1 Aug 2007, 05:12 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