Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Retrieving Sub-Cats cPath

    Trying to achieve what the thread title states:

    Latest Zen Cart Version Installed

    Custom Categories Side-box:

    Basically I am calling sub-categories and displaying in a div which is visible on:hover

    Example
    Attachment 13045

    If the main category has (no) sub-categories I am calling first 5 products and displaying in a div which is visible on:hover

    Example
    Attachment 13046

    I have used the following code but for some reason can not get it to execute:

    With sub-categories I use:

    PHP Code:
                    $cPath_new=zen_get_path($subcategories->fields['categories_id']);
                    
    $cPath_new=str_replace('=0_''='$cPath_new);
                    
    $cPath_new="cPath=".$subcategories->fields['categories_id'];
                    echo 
    '<li>'.'<a href="' zen_href_link(FILENAME_DEFAULT$cPath_new) . '">'.$subcategories->fields['categories_name'].'</a></li>'
    But it still returns:
    index.php?main_page=product_info&cPath=17&products_id=180

    Instead of:
    index.php?main_page=product_info&cPath=1_17&products_id=180


    For products I use:
    PHP Code:
                    $cPath_new=zen_get_path($categories->fields['categories_id']);
                    
    $cPath_new=str_replace('=0_''='$cPath_new);
                    echo 
    '<li>'.'<a href="'.zen_href_link(zen_get_info_page($products->fields['products_id']),$cPath_new'&products_id=' $products->fields['products_id']) . '">'.$products->fields['products_name'].'</a></li>'
    But it still returns:
    index.php?main_page=product_info&cPath=&products_id=115

    Instead of:
    index.php?main_page=product_info&cPath=53&products_id=115

    Any Ideas?

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

    Default Re: Retrieving Sub-Cats cPath

    Have you done a debug echo to see exactly what $cPath_new is before you use it?
    In the category version, you set $cPath_new in two different ways, the second wiping out the first.
    PHP Code:
    $cPath_new="cPath=".$subcategories->fields['categories_id']; 
    will give you only the one category id, not a path.

  3. #3
    Join Date
    Feb 2010
    Posts
    2,159
    Plugin Contributions
    17

    Default Re: Retrieving Sub-Cats cPath

    Quote Originally Posted by gjh42 View Post
    Have you done a debug echo to see exactly what $cPath_new is before you use it?
    In the category version, you set $cPath_new in two different ways, the second wiping out the first.
    PHP Code:
    $cPath_new="cPath=".$subcategories->fields['categories_id']; 
    will give you only the one category id, not a path.
    I think that I shouldn't stare at code for more than a few minutes at a time Glenn.

    Thanks for the direction, got it all fixed up now!

 

 

Similar Threads

  1. v150 How to display Top Cat & Sub Cat but not Sub Sub Cats??
    By spiggles87 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 5 Mar 2013, 06:37 PM
  2. sub cats a different colour to main cats?
    By Sushigal in forum Templates, Stylesheets, Page Layout
    Replies: 8
    Last Post: 13 Sep 2010, 04:15 PM
  3. Linking sub cats to multiple parent cats?
    By nadsab in forum Setting Up Categories, Products, Attributes
    Replies: 7
    Last Post: 8 Sep 2010, 04:41 PM
  4. Can I display sub cats under their main cats without having to click on main cats?
    By Sushigal in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 11 May 2009, 11:10 AM

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