Page 5 of 7 FirstFirst ... 34567 LastLast
Results 41 to 50 of 70
  1. #41
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default Re: Parent Categories Separated In 3 sideboxes

    A quick way to include all subcategories of a particular top cat is to type cast the value as an integer; any numbers following an _ will be discarded.
    PHP Code:
    $cPTest = (int)str_replace("cPath=","",$box_categories_array[$i]['path']);
    if(
    in_array($cPTestexplode(",",'3,7,7_25'))) {
      
    // code to be executed

    With three boxes to display different categories, copy this code into each one and adjust the numbers to reflect the desired top categories for that box.

    For actual use in a version of tpl_categories.php, find this
    PHP Code:
         if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else { 
    and change to this
    PHP Code:
         $cPTest = (int)str_replace("cPath=","",$box_categories_array[$i]['path']);
         if ((!
    in_array($cPTestexplode(",",'3,7,7_25'))) or zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else { 

  2. #42
    Join Date
    Jun 2007
    Posts
    54
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    Hi

    I have walked away for awhile try'd almost every expanded cat Mod out there, Couldn't get any of them to work.

    So I did your plan moved all cats to the top and used your code and it all works great. You have no idea how thankful I am for you help.

    Thank you

  3. #43
    Join Date
    Jan 2006
    Posts
    420
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    hey Glenn (GJH42) seems your quite an authority on the categories manipulation.

    Do you know if it is possible to use the methods you have described in the posts above to have the category sidebox that only displays the sub cats of the top level you are in ?

    You would chose the top level using the Category tabs at the top of the page , then the categories sidebox just show the subs of that top level one your in .

    thanks for any advice.
    Various Zen cart sites !

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

    Default Re: Parent Categories Separated In 3 sideboxes

    That's very easy.

    In /includes/templates/your_template/sideboxes/tpl_categories.php, find this
    PHP Code:
         if (zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else { 
    and add

    substr_count($box_categories_array[$i]['path'],'_') == 0 or

    to the if test to get this
    PHP Code:
    // subcat limit 2007-12-20
          
    if (substr_count($box_categories_array[$i]['path'],'_') == or zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else { 
    The number of underscores in $box_categories_array[$i]['path'] indicates the category level, with 0 being a top cat.

    The code can also be used to hide lower level subcats, with

    $box_categories_array[$i]['path'] > 1

    For more discussion of this, see the original thread Hide top category - Skip to subcategories.

  5. #45
    Join Date
    Jan 2006
    Posts
    420
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    Cheers pal that works great .

    Do you have examples of others that have done it ? just wanted to see what they do for the home page , maybe put another if statement in to ignore if home page ?

    can i also ask if I wanted to change the Sidebox title to the top level cat ...

    I assume i would change this bit

    $title = BOX_HEADING_CATEGORIES;

    But not sure what to put in there . Thanks
    Various Zen cart sites !

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

    Default Re: Parent Categories Separated In 3 sideboxes

    The simplest way to deal with this is to make an exception for the current top cat, so that it displays in the sidebox. Then it can be styled to look like a box title, and the real box title can be hidden with CSS.

    change the new code to

    (substr_count($box_categories_array[$i]['path'],'_') == 0 and !$box_categories_array[$i]['current']) or

    and add it to the if test to get this
    PHP Code:
    // subcat limit 2007-12-20
          
    if ((substr_count($box_categories_array[$i]['path'],'_') == and !$box_categories_array[$i]['current']) or zen_get_product_types_to_category($box_categories_array[$i]['path']) == or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
            
    // skip if this is for the document box (==3)
          
    } else { 

  7. #47
    Join Date
    May 2008
    Posts
    31
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    hello i been trying too many diferents ways but is not working for me can anybody help me with this

    i try and i want this like from crazycucumber post#43

    Do you know if it is possible to use the methods you have described in the posts above to have the category sidebox that only displays the sub cats of the top level you are in ?

    You would chose the top level using the Category tabs at the top of the page , then the categories sidebox just show the subs of that top level one your in .
    i Glenn has the anwser but i cant figure out

    one of my top categories is 2
    TOP Categorie
    2

    Subs
    2_7
    2_8
    2_9

    where i put this?

    from Glenn
    That's very easy.

    In /includes/templates/your_template/sideboxes/tpl_categories.php, find this
    PHP Code:
    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 {

    and add

    substr_count($box_categories_array[$i]['path'],'_') == 0 or

    to the if test to get this

    PHP Code:
    // subcat limit 2007-12-20
    if (substr_count($box_categories_array[$i]['path'],'_') == 0 or 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 {

    The number of underscores in $box_categories_array[$i]['path'] indicates the category level, with 0 being a top cat.

    The code can also be used to hide lower level subcats, with

    $box_categories_array[$i]['path'] > 1
    i try exactly how glenn explain but im only getting errors blank pages....im only see my header

    thanks

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

    Default Re: Parent Categories Separated In 3 sideboxes

    What exactly does that area of your tpl_categories.php look like now?

  9. #49
    Join Date
    May 2008
    Posts
    31
    Plugin Contributions
    0

    Default Re: Parent Categories Separated In 3 sideboxes

    hello glenn.....this is what i have right now

    <?php
    /**
    * Side Box Template
    *
    * @package templateSystem
    * @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: tpl_categories.php 4162 2006-08-17 03:55:02Z ajeh $
    */
    $content = "";

    $content .= '<div id="' . str_replace('_', '-', $box_id . 'Content') . '" class="sideBoxContent">' . "\n";
    for ($i=0;$i<sizeof($box_categories_array);$i++) {
    /* test for cats to display */
    if ($box_categories_array[$i]['path'] == ('cPath=2' or 'cPath=2_7' or 'cPath=2_8' or 'cPath=2_9')) {

    switch(true) {
    // to make a specific category stand out define a new class in the stylesheet example: A.category-holiday
    // uncomment the select below and set the cPath=3 to the cPath= your_categories_id
    // many variations of this can be done
    // case ($box_categories_array[$i]['path'] == 'cPath=2'):
    // $new_style = 'category-holiday';
    // break;
    case ($box_categories_array[$i]['top'] == 'true'):
    $new_style = 'category-top';
    break;
    case ($box_categories_array[$i]['has_sub_cat']):
    $new_style = 'category-subs';
    break;
    default:
    $new_style = 'category-products';
    }


    // subcat limit 2007-12-20
    if (substr_count($box_categories_array[$i]['path'],'2') == 0 or zen_get_product_types_to_category($box_categories_array[$i]['path']) == 2 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
    // skip if this is for the document box (==2)
    } else {


    $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';

    if ($box_categories_array[$i]['current']) {
    if ($box_categories_array[$i]['has_sub_cat']) {
    $content .= '<span class="category-subs-parent">' . $box_categories_array[$i]['name'] . '</span>';
    } else {
    $content .= '<span class="category-subs-selected">' . $box_categories_array[$i]['name'] . '</span>';
    }
    } else {
    $content .= $box_categories_array[$i]['name'];
    }

    if ($box_categories_array[$i]['has_sub_cat']) {
    $content .= CATEGORIES_SEPARATOR;
    }
    $content .= '</a>';

    if (SHOW_COUNTS == 'true') {
    if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
    $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
    }
    }

    $content .= '<br />' . "\n";
    }
    } /* end cat display test */
    /* clubewear for cats to display */
    if ($box_categories_array[$i]['path'] == ('cPath=1' or 'cPath=1_3')) {

    switch(true) {
    // to make a specific category stand out define a new class in the stylesheet example: A.category-holiday
    // uncomment the select below and set the cPath=3 to the cPath= your_categories_id
    // many variations of this can be done
    // case ($box_categories_array[$i]['path'] == 'cPath=1'):
    // $new_style = 'category-holiday';
    // break;
    case ($box_categories_array[$i]['top'] == 'true'):
    $new_style = 'category-top';
    break;
    case ($box_categories_array[$i]['has_sub_cat']):
    $new_style = 'category-subs';
    break;
    default:
    $new_style = 'category-products';
    }


    // subcat limit 2007-12-20
    if (substr_count($box_categories_array[$i]['path'],'1') == 0 or zen_get_product_types_to_category($box_categories_array[$i]['path']) == 1 or ($box_categories_array[$i]['top'] != 'true' and SHOW_CATEGORIES_SUBCATEGORIES_ALWAYS != 1)) {
    // skip if this is for the document box (==1)
    } else {


    $content .= '<a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';

    if ($box_categories_array[$i]['current']) {
    if ($box_categories_array[$i]['has_sub_cat']) {
    $content .= '<span class="category-subs-parent">' . $box_categories_array[$i]['name'] . '</span>';
    } else {
    $content .= '<span class="category-subs-selected">' . $box_categories_array[$i]['name'] . '</span>';
    }
    } else {
    $content .= $box_categories_array[$i]['name'];
    }

    if ($box_categories_array[$i]['has_sub_cat']) {
    $content .= CATEGORIES_SEPARATOR;
    }
    $content .= '</a>';

    if (SHOW_COUNTS == 'true') {
    if ((CATEGORIES_COUNT_ZERO == '1' and $box_categories_array[$i]['count'] == 0) or $box_categories_array[$i]['count'] >= 1) {
    $content .= CATEGORIES_COUNT_PREFIX . $box_categories_array[$i]['count'] . CATEGORIES_COUNT_SUFFIX;
    }
    }

    $content .= '<br />' . "\n";
    }
    } /* end cat display clubwear */
    }

    if (SHOW_CATEGORIES_BOX_SPECIALS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true' or SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true' or SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
    // display a separator between categories and links
    if (SHOW_CATEGORIES_SEPARATOR_LINK == '1') {
    $content .= '<hr id="catBoxDivider" />' . "\n";
    }
    if (SHOW_CATEGORIES_BOX_SPECIALS == 'true') {
    $show_this = $db->Execute("select s.products_id from " . TABLE_SPECIALS . " s where s.status= 1 limit 1");
    if ($show_this->RecordCount() > 0) {
    $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_SPECIALS) . '">' . CATEGORIES_BOX_HEADING_SPECIALS . '</a>' . '<br />' . "\n";
    }
    }
    if (SHOW_CATEGORIES_BOX_PRODUCTS_NEW == 'true') {
    // display limits
    // $display_limit = zen_get_products_new_timelimit();
    $display_limit = zen_get_new_date_range();

    $show_this = $db->Execute("select p.products_id
    from " . TABLE_PRODUCTS . " p
    where p.products_status = 1 " . $display_limit . " limit 1");
    if ($show_this->RecordCount() > 0) {
    $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_NEW) . '">' . CATEGORIES_BOX_HEADING_WHATS_NEW . '</a>' . '<br />' . "\n";
    }
    }
    if (SHOW_CATEGORIES_BOX_FEATURED_PRODUCTS == 'true') {
    $show_this = $db->Execute("select products_id from " . TABLE_FEATURED . " where status= 1 limit 1");
    if ($show_this->RecordCount() > 0) {
    $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_FEATURED_PRODUCTS) . '">' . CATEGORIES_BOX_HEADING_FEATURED_PRODUCTS . '</a>' . '<br />' . "\n";
    }
    }
    if (SHOW_CATEGORIES_BOX_PRODUCTS_ALL == 'true') {
    $content .= '<a class="category-links" href="' . zen_href_link(FILENAME_PRODUCTS_ALL) . '">' . CATEGORIES_BOX_HEADING_PRODUCTS_ALL . '</a>' . "\n";
    }
    }
    $content .= '</div>';
    ?>
    i try with 2 of my categories

    thank you

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

    Default Re: Parent Categories Separated In 3 sideboxes

    // subcat limit 2007-12-20
    if (substr_count($box_categories_array[$i]['path'],'2') == 0 or

    This is going to hide the category if there are no "2" characters in the category's cPath.

    I somehow don't think this will give the results you want.

    If you want to hide all of your top cats, use the code exactly as I first gave it:

    if (substr_count($box_categories_array[$i]['path'],'_') == 0 or ...

 

 
Page 5 of 7 FirstFirst ... 34567 LastLast

Similar Threads

  1. Category Filter - Display Parent categories
    By djdavedawson in forum General Questions
    Replies: 1
    Last Post: 5 Oct 2010, 10:08 PM
  2. Subcategories products in Parent Categories
    By fightthefourwalls in forum Setting Up Categories, Products, Attributes
    Replies: 21
    Last Post: 14 Jun 2010, 07:58 PM
  3. Enable Links for Parent Categories in Categories Sidebox
    By MrsQ in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 11 Sep 2009, 08:25 PM
  4. Parent... Child... Sub.... CATEGORIES
    By eliza-bee in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 12 May 2009, 03:03 PM
  5. Parent categories in dropdown filter
    By Ben in forum Customization from the Admin
    Replies: 3
    Last Post: 15 Aug 2006, 02:38 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