Results 1 to 10 of 10

Hybrid View

  1. #1
    Join Date
    Aug 2009
    Posts
    48
    Plugin Contributions
    0

    Default How to turn off left column for one category and all of its sub categories?

    I've used the following code in the templates/CUSTOM/common/tpl_mainpage.php file to disable the left column for a particular category:

    Code:
    if ($current_page_base == 'index' and $cPath == '275') {
    	$flag_disable_left = true;
    	}
    However, I would like to be able to do the same for all the subcategories under that category, without having to list them all (there is a lot). Is this possible using a wildcard of some sort? For instance:

    Code:
    if ($current_page_base == 'index' and $cPath == '275***') {
    	$flag_disable_left = true;
    	}
    Thanks in advance for any help.
    20th Century Glass - Antique & Collectable Glass Store

  2. #2
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,871
    Plugin Contributions
    96

    Default Re: How to turn off left column for one category and all of it's sub categories?

    Is 275 the top-level category? That is, is the cPath for all the categories for which you want to hide the sidebox of the form 275_xxx or 275_xxx_yyy?

    If so, you could use:
    Code:
    if ($current_page_base == 'index' && strpos($cPath, '275') === 0 ) {
      $flag_disable_left = true;
    }
    Make sure that you use the === (3 equals signs) for exactly equal to.

  3. #3
    Join Date
    Aug 2009
    Posts
    48
    Plugin Contributions
    0

    Default Re: How to turn off left column for one category and all of it's sub categories?

    Works perfectly, thanks!
    20th Century Glass - Antique & Collectable Glass Store

  4. #4
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    13,871
    Plugin Contributions
    96

    Default Re: How to turn off left column for one category and all of it's sub categories?

    Thanks for reporting back that that worked for you! I realized that there might be an issue, once your category_id values get into the 2700 range; a more complete, future-proofed solution is:
    Code:
    if ($current_page_base == 'index' && strpos($cPath, '275_') === 0 ) {
      $flag_disable_left = true;
    }
    Adding the underscore (_) to the end makes sure that the category starts with 275_ so that category 2750 won't satisfy the 'if' statement.

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

    Default Re: How to turn off left column for one category and all of it's sub categories?

    You probably want a modification of the test to account for the top category page as well as subcats...
    PHP Code:
    if ($current_page_base == 'index' && ($cPath == '275' or strpos($cPath'275_') === )) {
      
    $flag_disable_left true;


  6. #6
    Join Date
    Aug 2009
    Posts
    48
    Plugin Contributions
    0

    Default Re: How to turn off left column for one category and all of it's sub categories?

    Thanks again!
    20th Century Glass - Antique & Collectable Glass Store

 

 

Similar Threads

  1. Turn off left sidebox in all but categories page
    By Matthew Kin in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 5 Mar 2015, 01:53 PM
  2. Turn Off Better Categories for Sub-Category
    By Craig Robbo in forum All Other Contributions/Addons
    Replies: 0
    Last Post: 29 Jun 2009, 03:45 AM
  3. how to turn off all product listings and only show categories?
    By fa11s in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 20 Feb 2009, 08:34 PM
  4. Turn off left/right column for certain pages
    By Berserker in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 27 Feb 2008, 02:55 AM
  5. IF statement to turn off left/right column on category page
    By milkyway in forum General Questions
    Replies: 6
    Last Post: 1 Oct 2007, 08:26 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