Results 1 to 10 of 10
  1. #1
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Idea or Suggestion Twitch Hide Any Category

    Twitch Hide Any Category v1.0

    Completed Feb 1st 2012 tested on ZenCart version 1.39h

    This modification will allow you to hide any category you specify in includes/templates/YOUR_TEMPLATE/sideboxes/tpl_categories.php.

    Simply replace/add in the code below to manually hide categories.

    How it works:
    As the sidebox php loop runs it simply outputs <basic html tags along with> <your category title> creating the sidebox with the many categories you see.

    This code will 'empty' the $content variable for the specific category you choose before it gets wrapped in html code. It's a very simple output filter.

    Any category can be removed regardless of it's hierarchy.

    I have tested it on a ZenCart 1.39h with multisite, wholesale, dual pricing and a host of other custom mods without any complications.

    • Step 1

    Change this:

    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 {
    $content .= '<li><div class="betterCategories"><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    if ($box_categories_array[$i]['current']) {


    To this:
    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 {

    //Twitch Hide Any Category Step 1 of 2 - Jan 31 2012 starts
    if ($box_categories_array[$i] ['path'] == 'cPath=3_10') {
    //this line filters out the cPath=CategoryYouWantToHide
    $content .= '';
    //this line clears the line data so it will NOT be inserted into the sidebox
    } else {
    //repeat 5 lines above to remove another category you MUST ADD AN END BRACKET below
    if ($box_categories_array[$i] ['path'] == 'cPath=3_7') {
    //this line filters out the cPath=CategoryYouWantToHide
    $content .= '';
    //this line clears the line data so it will NOT be inserted into the sidebox
    } else {
    //repeat 5 lines above to remove another category you MUST ADD AN END BRACKET below
    //Twitch Hide Any Category Step 1 of 2 - Jan 31 2012 ends

    $content .= '<li><div class="betterCategories"><a class="' . $new_style . '" href="' . zen_href_link(FILENAME_DEFAULT, $box_categories_array[$i]['path']) . '">';
    if ($box_categories_array[$i]['current']) {


    • Step 2

    Change this:

    $content .= '</div></li>' . "\n";
    //$content .= '<br />' . "\n";
    }
    }


    To this:

    $content .= '</div></li>' . "\n";
    //$content .= '<br />' . "\n";
    }
    }
    //Twitch Hide Any Category Step 2 of 2 - Jan 31 2012 starts
    //IMPORTANT - For each category you remove add one end bracket below
    }}
    //Twitch Hide Any Category Step 2 of 2 - Jan 31 2012 ends

    • That's It!

    You will notice it is setup to remove 2 categories - 3_10 and 3_7 - which are not in any numeric order. Just add another 5 lines of code in step 1 along with the end bracket in step 2 if you want to hide another category.

    Feel free to report your findings and uses of this code in this thread!

    Twitch.

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

    Default Re: Twitch Hide Any Category

    Note: since tpl_categories.php has not changed in a long time, this will work on any version from before v1.3.7 to v1.5.0.

    Your example is customized to run on a betterCategories tpl_categories.php file, which is quite different in this area from a stock file.

    $content .= '';
    //this line clears the line data so it will NOT be inserted into the sidebox
    .= '' does not clear anything; for that you would want = ''.
    Last edited by gjh42; 1 Feb 2012 at 11:15 PM.

  3. #3
    Join Date
    Apr 2007
    Location
    Ontario, Canada
    Posts
    1,731
    Plugin Contributions
    27

    Default Re: Twitch Hide Any Category

    Quote Originally Posted by gjh42 View Post
    Note: since tpl_categories.php has not changed in a long time, this will work on any version from before v1.3.7 to v1.5.0.

    Your example is customized to run on a betterCategories tpl_categories.php file, which is quite different in this area from a stock file.

    .= '' does not clear anything; for that you would want = ''.
    Failing to include the period before the equal sign will break the sidebox code. It is necessary in this version of the file.

    I will upload the stock code for ZenCart 1.50 after testing later today.

    Twitch.

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

    Default Re: Twitch Hide Any Category

    If $content already holds prior item output, then you would obviously not want to clear it; but .= '' will do absolutely nothing and I don't see the point of including it.

    Anyway, this concept is a good option to make available for people. Thanks for presenting it.

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

    Default Re: Twitch Hide Any Category

    Looking closer at your code, you have a series of new nested if() { }else{ }statements. This is an inefficient method which could be streamlined by simply using one
    if() {
    }elseif(){
    }elseif(){
    }else{
    }
    statement, which would not require keeping track of numbers of nested } at the bottom. Only one new } would be needed.

    Better yet would be to put the list of excluded cPaths in one place, requiring nothing more than adding a number to include a new cPath in the list. Something like this
    PHP Code:
    if (in_array(str_replace('cPath=','',$box_categories_array[$i] ['path']), explode(',''3_10,3_7,5_23,9')) {
     
    //do nothing
    }else{
     
    //the standard code


  6. #6
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Re: Twitch Hide Any Category

    So Glen what is the proper way to implement this in Zen 1.5.1?

    I have created the Gift Certificate under it's own category, and I do not want it to show it in the left box. I would manually add the path to the product Category where I want it to appear on the site pages.

    Is there a better more proper way to achieve this.
    Using Zen Cart 1.5.1

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

    Default Re: Twitch Hide Any Category

    Using the stock tpl_categories.php as a base:
    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 {
          
    $content .= '<a class="' $new_style '" href="' zen_href_link(FILENAME_DEFAULT$box_categories_array[$i]['path']) . '">'
    add this to the if() test
    PHP Code:
    or (in_array(str_replace('cPath=','',$box_categories_array[$i] ['path']), explode(',''3_10,3_7,5_23,9'))/*hidden categories*/ 
    to get
    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) or (in_array(str_replace('cPath=','',$box_categories_array[$i] ['path']), explode(',''3_10,3_7,5_23,9'))/*hidden categories*/) {
            
    // skip if this is for the document box (==3)
          
    } else {
          
    $content .= '<a class="' $new_style '" href="' zen_href_link(FILENAME_DEFAULT$box_categories_array[$i]['path']) . '">'
    This is all you need to do to hide categories 3_10, 3_7, 5_23 and 9 in the categories sidebox. Adjust the list as desired. You may also want to hide it in other places, which would be another job entirely..

  8. #8
    Join Date
    Dec 2012
    Posts
    607
    Plugin Contributions
    0

    Default Re: Twitch Hide Any Category

    Thank you Glen.
    Using Zen Cart 1.5.1

  9. #9
    Join Date
    Feb 2010
    Posts
    16
    Plugin Contributions
    0

    Default Re: Twitch Hide Any Category

    I just tried this code modification using 'Categories Dressing' tpl_categories. I still can't hide my categories.

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

    Default Re: Twitch Hide Any Category

    What exactly did you do to try to hide your category? Post your version (in php tags) so we can troubleshoot.

 

 

Similar Threads

  1. v151 Twitch Wholesale with Twitch Wholesale Attributes
    By twitchtoo in forum All Other Contributions/Addons
    Replies: 162
    Last Post: 8 Oct 2021, 06:21 PM
  2. v151 Hide one category from category side box
    By robbie269 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 18 Feb 2014, 03:35 PM
  3. v150 Any way to show/hide payment modules dynamically based on order total?
    By Limitless in forum Addon Payment Modules
    Replies: 2
    Last Post: 27 Sep 2012, 03:22 PM
  4. v150 Hide any of the Drop Downs in abbington_mega templete
    By Adam1 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 18 May 2012, 03:57 PM
  5. Remove / Hide category link from category image on home page
    By Sushigal in forum Templates, Stylesheets, Page Layout
    Replies: 11
    Last Post: 15 Mar 2010, 11:50 PM

Bookmarks

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
Zen-Cart, Internet Selling Services, Klamath Falls, OR