Results 1 to 10 of 14

Hybrid View

  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

 

 

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