Page 1 of 2 12 LastLast
Results 1 to 10 of 14
  1. #1
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    red flag Hide single category tab

    Hi I need to hide a single category tab from the categories tabs menu in the header, but not anywhere else.

    I gathered that if I could create a separate style for each category tab then I would be able to just hide the category tab I don't want visible with CSS using display:none;

    So the categories would be like this

    category 1 = style1

    category 2 = style2

    category 3 = style3

    So if I wanted to his category 3 I would do something like this

    #navCatTabs .style3 {
    display:none;
    }

    Or if you want to look at it in zen code

    #navCatTabs .category-top3 {
    display:none;
    }

    So I need some way of creating a separate style for each tab. This would simply mean adding a number onto the end of 'category-top' in order.

    so the tabs would be .category-top1, .category-top2, .category-top3 etc in order. The number could probably be pulled from the sort order number.

    How would I go about this?




    Thanks

    Nick
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

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

    Default Re: Hide single category tab

    You could do exactly what you asked with an edit to one line in tpl_modules_categories_tabs.php, but that would fail if you added or removed a top category that displays to the left of your hidden category.
    For a better method that will hide the specific category, not the position, find this in
    /includes/modules/your_template/categories_tabs.php
    PHP Code:
      // currently selected category
      
    if ((int)$cPath == $categories_tab->fields['categories_id']) {
        
    $new_style 'category-top';
        
    $categories_tab_current '<span class="category-subs-selected">' $categories_tab->fields['categories_name'] . '</span>';
      } else {
        
    $new_style 'category-top';
        
    $categories_tab_current $categories_tab->fields['categories_name'];
      } 
    Change the two lines
    PHP Code:
        $new_style 'category-top'
    to
    PHP Code:
        $new_style 'category-top cat' $categories_tab->fields['categories_id']; 
    Now you can address each link individually like .cat23 {display: none;}

    If your cat-tabs bar has tab styling that involves the <li> element, you will need to hide the whole tab, not just the link. Find in
    /includes/templates/your_template/templates/tpl_modules_categories_tabs.php
    PHP Code:
      <li><?php echo $links_list[$i];?></li>
    Change to
    PHP Code:
      <li class="<?php echo substr($links_list[$i], 23, (strpos('" hr'$links_list[$i]) - 23));?>"><?php echo $links_list[$i];?></li>
    If there are any issues with this, let me see the site and I can adjust the substr/strpos details.

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

    Default Re: Hide single category tab

    You could also do a brute-force CSS solution, which would hide only the given tab position, not a specific category, but would not require editing any PHP files.
    To hide only the third tab:

    #navCatTabs li+li+li {display: none;}
    #navCatTabs li+li+li+li {display: inline;}

    You have to explicitly set the fourth and following tabs back to whatever display status they were.

  4. #4
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Hide single category tab

    Hi Glenn, I opted for the PHP option as it suits me better and I think works better overall.

    This line

    $new_style = 'category-top cat' . $categories_tab->fields['categories_id'];

    works a treat, however

    This line

    <li class="<?php echo substr($links_list[$i], 23, (strpos('" hr', $links_list[$i]) - 23));?>"><?php echo $links_list[$i];?></li>

    breaks the cPath links and throws up errors.

    Instead of cPath you get code like the following

    <ul>
    <li class="cat2" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=2">C"><a class="category-top cat2" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=2">Chesterfield Suites</a> </li>
    <li class="cat1" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=1"><span class="category-subs-selected">Chester"><a class="category-top cat1" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=1"><span class="category-subs-selected">Chesterfield Sofas</span></a> </li>
    <li class="cat3" href="http://WEBSITE.com/index.php?main_page=index&amp;cP"><a class="category-top cat3" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=3">Club Chairs</a> </li>
    <li class="cat4" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath="><a class="category-top cat4" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=4">Wingback Chairs</a> </li>
    <li class="cat5" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=5">Fo"><a class="category-top cat5" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=5">Footstools and Boxes</a> </li>
    <li class="cat6" href="http://WEBSITE.com/index.php?main_page=index&amp;cPa"><a class="category-top cat6" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=6">Study Chairs</a> </li>
    <li class="cat7" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=7">"><a class="category-top cat7" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=7">Used Chesterfields</a> </li>
    <li class="cat8" href="http://WEBSITE.com/index.php?main_page=index&amp;cPa"><a class="category-top cat8" href="http://WEBSITE.com/index.php?main_page=index&amp;cPath=8">Leather Care</a> </li>
    </ul>

    If the above can be fixed then I think its worthy of a small mod since I'm not the only one looking for a solution to this.

    Thanks very much so far, just needs the above fixing.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

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

    Default Re: Hide single category tab

    Oops, I left out part of the strpos() syntax. This line
    PHP Code:
    <li class="<?php echo substr($links_list[$i], 23, (strpos('" hr'$links_list[$i]) - 23));?>"><?php echo $links_list[$i];?></li>
    should be
    PHP Code:
    <li class="<?php echo substr($links_list[$i], 23, (strpos($links_list[$i], '" hr'$links_list[$i]) - 23));?>"><?php echo $links_list[$i];?></li>

  6. #6
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Hide single category tab

    Fantastic Glenn, thanks very much indeed. This will save me loads of time.

    Are you going to package this up into a mod? Seems such a basic thing, but one that doesn't ever seem to have been solved before so I think its definitely worth a mod.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

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

    Default Re: Hide single category tab

    I have packaged up a mod, and would appreciate people trying it before I submit it to Plugins. Please post your experience here if you install it.
    Attachment 11468

  8. #8
    Join Date
    Apr 2007
    Location
    Dayton, Ohio
    Posts
    682
    Plugin Contributions
    0

    Default Re: Hide single category tab

    Quote Originally Posted by gjh42 View Post
    I have packaged up a mod, and would appreciate people trying it before I submit it to Plugins. Please post your experience here if you install it.
    Attachment 11468
    This mod works well on Zen Cart v1.5.1. Its only 2 files is very easy to use and install, and did not conflict with any of my other 10 modules currently installed. I wish all mods were this simple. Oh yeah, if you are running the companion module (Category Dressing) for another styling the side menu, these will both work hand in hand. Instructions were very clear. Thank you so much!

  9. #9
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Hide single category tab

    Yes thanks for this, very simple but one of those things that seems to have previously been overlooked. This opens up plenty of ways to CSS category tabs as well as hiding them.
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

  10. #10
    Join Date
    Sep 2008
    Location
    Cleethorpes
    Posts
    1,229
    Plugin Contributions
    6

    Default Re: Hide single category tab

    Glenn, here's another one which would be handy and probably require something similar written.

    Currently I have some modified code which adds an body id to each category

    so you get <body id="category1">

    What would be really cool is if we were also able to control the display of certain elements on each product page using body class as well as ID.

    So you would have something like this <body id="category1" class="my-amazing-product">, where my-amazing-product is the product name which would normally be My Amazing Product with uppercase letters and lowercase letters and without dashes in between.

    In short, when you name a product called My Amazing Product in the admin is adds a class to the product info page called my-amazing-product
    Nick Smith - Venture Design and Print
    https://venturedesignandprint.co.uk

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. 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
  2. Hide a single category from the side menu
    By NoobGal in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 7 May 2011, 02:34 PM
  3. Hide single category on homepage?
    By twdhosting in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 19 Jan 2011, 10:54 AM
  4. category tab contributions?
    By deemurphy in forum All Other Contributions/Addons
    Replies: 11
    Last Post: 7 Apr 2010, 02:33 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

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