If this is your first visit, check our documentation. To post, register or login.
Forums / Customizing the Look of Your Shop / Templates, Stylesheets, Page Layout / How to turn off left column for one category and all of its sub categories?

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

Started by waynestephens on 3 May 2013, 2:09 PM · Views: 1,694

Results 1 to 10 of 10
3 May 2013, 2:09 PM
#1
waynestephens avatar

waynestephens

New Zenner

Join Date:
Aug 2009
Posts:
48
Plugin Contributions:
0

Post #1 by waynestephens

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

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:

if ($current_page_base == 'index' and $cPath == '275***') {
	$flag_disable_left = true;
	}

Thanks in advance for any help. :smile:

20th Century Glass - Antique & Collectable Glass Store

4 May 2013, 8:19 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,152
Plugin Contributions:
56

Post #2 by lat9

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:

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.

5 May 2013, 12:16 PM
#3
waynestephens avatar

waynestephens

New Zenner

Join Date:
Aug 2009
Posts:
48
Plugin Contributions:
0

Post #3 by waynestephens

Works perfectly, thanks! :smile:

20th Century Glass - Antique & Collectable Glass Store

5 May 2013, 12:21 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,152
Plugin Contributions:
56

Post #4 by lat9

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:

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.

6 May 2013, 1:30 PM
#5
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,874
Plugin Contributions:
8

Post #5 by gjh42

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

6 May 2013, 4:21 PM
#6
waynestephens avatar

waynestephens

New Zenner

Join Date:
Aug 2009
Posts:
48
Plugin Contributions:
0

Post #6 by waynestephens

Thanks again! :smile:

20th Century Glass - Antique & Collectable Glass Store

7 Jul 2016, 6:11 PM
#7
monkeyjr47906 avatar

monkeyjr47906

New Zenner

Join Date:
Nov 2007
Posts:
72
Plugin Contributions:
0

Post #7 by monkeyjr47906

Sorry to jump on an old thread but I'm trying to figure out how to hide a left column ONLY on category pages that list products. (I have some category pages that list subcategories)

7 Jul 2016, 6:26 PM
#8
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,152
Plugin Contributions:
56

Post #8 by lat9

Try:

if ($current_page_base == 'index' && $category_depth == 'products') {
    $flag_disable_left = true;
}
8 Jul 2016, 6:29 PM
#9
monkeyjr47906 avatar

monkeyjr47906

New Zenner

Join Date:
Nov 2007
Posts:
72
Plugin Contributions:
0

Post #9 by monkeyjr47906

YES! Works perfectly! I had already done the hard way (exploding all the category numbers with product listings), but this method will save me a lot of work in the future. Thanks!

8 Jul 2016, 6:50 PM
#10
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,152
Plugin Contributions:
56

Post #10 by lat9

No problem; that solution was created by inspecting the file /includes/pages/index/header_php.php to see what "distinctions" it made for the various (index_home, index_categories, index_products) index-page displays.