Forums / Templates, Stylesheets, Page Layout / Turning off columns on selected pages

Turning off columns on selected pages

Locked

Views: 1,055

Results 1 to 4 of 4
This thread is locked. New replies are disabled.
27 Mar 2007, 7:05 PM
#1
red8ii8 avatar

red8ii8

New Zenner

Join Date:
Feb 2007
Posts:
38
Plugin Contributions:
0

Turning off columns on selected pages

I'm not familiar with php syntax and am trying to follow the tutorial on this page
I've successfully turned off the right column (the left is globally turned off already via admin) on the contact us and privacy pages, but I can't seem to get it to dissapear on the category pages. I want it off on the main subcategory page and the individual product listing. I'm pretty sure it has to with me not naming correctly. This is what I have (the first chunk works the second no.)

if (in_array($current_page_base,explode(",",'contact_us,privacy')) ) {
    $flag_disable_right = true;
    $flag_disable_left = true;
  }
  if (in_array($cPath,explode(",",'3,8')) ) {
    $flag_disable_right = true;
    $flag_disable_left = true;
  }
```Any help is appreciated!

Jessica
[www.thepearltrader.com](http://www.thepearltrader.com)
28 Mar 2007, 6:52 AM
#2
gjh42 avatar

gjh42

Black Belt

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

Re: Turning off columns on selected pages

I don't have that much experience with PHP either, but this statement is saying "if the value of cPath is equal to any of the elements of the array (3 or 8 in your example) then execute the following...

CPath will only be 3 or 8 in top cat id 3 or 8, not in any subcats (it will be 3_42 or 8_17 or whatever in the subcats.) If it is a specific subcat(s) you want to affect, find the full cPath and use that.

If it is all subcats and product info pages that you want, cPath won't work. For product info pages, just add product_info to the $current_page_base list.
Any subcat will have at least one _ in the cPath, so you can test for that case. There is a PHP function called ereg() which is able to evaluate a string for the presence of almost any substring - look at a PHP tutorial or textbook. It is quite complicated, but powerful, and finding if cPath contains a _ should be relatively easy. I used it to display an appropriate category title image for certain categories or any of their subs and that took a lot of trial & error. There are probably Zen-specific functions that can accomplish all this easier and more elegantly...

28 Mar 2007, 7:13 AM
#3
gjh42 avatar

gjh42

Black Belt

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

Re: Turning off columns on selected pages

Here is an example of how I displayed the top cat title for the top, any sub or product info page in that category.

<!-- bof  collection title image - gjh42  20070223 -->
<?php
if ($current_page_base == ("index" or "product_info"))
{?>
  <div id="collectionTitleImage"> <?php
  if (ereg("(^1$|^1_)",$cPath)) //wedding or sub (cPath = or beginning with cat id 1 & not 11, 12, 13 etc.)
  { 
    echo "<img src='" . HTTP_SERVER . DIR_WS_CATALOG . "/images/frheadwed.gif' alt='The Wedding and Betrothal Collection'>";
  }
  elseif (ereg("(^2$|^2_)",$cPath)) //celtic or sub (cPath = or beginning with cat id 2)
  {
    echo "<img src='" . HTTP_SERVER . DIR_WS_CATALOG . "/images/frheadcel.gif' alt='The Celtic Collection'>";
  }
  elseif...

You could use
if (ereg("_",$cPath)) to find out if there is an _ in cPath.

28 Mar 2007, 10:23 PM
#4
red8ii8 avatar

red8ii8

New Zenner

Join Date:
Feb 2007
Posts:
38
Plugin Contributions:
0

Re: Turning off columns on selected pages

Aha! I get it. And I can just mouse over the link to the page I want to find the name for and the cPath number (or page name) is at the end of the sting at the bottom of my browser. Brilliant. All better thank you! :D