Zen Cart Logo
Forums / General Questions / Show/Hide sideboxes based on page

Show/Hide sideboxes based on page

Views: 43,781

Results 1 to 20 of 189
24 Aug 2006, 7:52 PM
#1
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Show/Hide sideboxes based on page

Not sure if anyone has written anything along these lines and a search didn't seem to turn up anything...

My company has a need to have a contribution that permits selectively showing/hiding sideboxes based on the particular page ZC is rendering. Perhaps, by programatically selecting a different layout based on the page requested. I was considering writing such a contrib but don't want to re-invent the wheel if it has already been done...

Anyone have any info on such a contrib?

Thank you very much!

Jeff

24 Aug 2006, 11:39 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Show/Hide sideboxes based on page

A straightforward way of achieving this is to use page-based stylesheets to determine which pages do or do not display certain sideboxes. For example, if you only wanted the shopping cart to appear on the contact_us page (deliberately silly example) then you would set the shopping cart sidebox to be on in Admin but include the following in your stylesheet> #shoppingcart {display:none}You would then create a css file called contact_us.css that contains only the line > shoppingcart {display:block}

24 Aug 2006, 11:49 PM
#3
patski avatar

patski

Zen Follower

Join Date:
Nov 2004
Location:
Deal, Kent, UK
Posts:
325
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

That is very clever - often wondered about how to do it but never bothered to investigate - thanks for the tip!

25 Aug 2006, 5:15 PM
#4
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

Thank you kuroi for your suggestion!! I will have to play with this a while to see if it will do the trick but other than efficiency (due to the fact that the sidboxes are still being processed) it is still a very clever way!

Again, thanks!

Jeff

25 Aug 2006, 9:24 PM
#5
whiteboxer avatar

whiteboxer

New Zenner

Join Date:
Apr 2006
Location:
Columbus, OH
Posts:
97
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

I was just forwarded this thread because I have a similar situation. How would this technique work with specific product pages? More specifically, the cart generates a list of numbers to determine the product pages (at least in the URL window). How would I attach the css file for a product category, for example, books?

25 Aug 2006, 9:28 PM
#6
jeffd avatar

jeffd

Totally Zenned

Join Date:
Sep 2004
Posts:
605
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

Take a look at the top of common/tpl_main_page.php where you can specify a list of comma delimited page names to hide sideboxes on. This may be a better solution than css for your purpose.

Jeff

25 Aug 2006, 10:16 PM
#7
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Show/Hide sideboxes based on page

The common/tpl_main_page.php approach allows you to turn off whole columns based on some fairly precise criteria. The code you need is already embedded as comments in the header ready to be enabled. If you want to turn off individual sideboxes based on category, then you could wrap similar conditional php statements around the code in the relevant includes/modules/sideboxes files.

If you're not so confident about coding, then much easier (though as Jeff rightly observes, less efficient) would be to create stylesheets with names such as c_aa.css for a category with ID aa, c_aa_bb.css for subcatory bb or category aa and p_cc.css for a product with ID cc. You can find out your category and product IDs by going to Admin > Categories/Products

26 Aug 2006, 5:38 AM
#8
misty avatar

misty

Inactive

Join Date:
Apr 2004
Location:
UK
Posts:
5,752
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

Quote:
#shoppingcart {display:none}

You would then create a css file called contact_us.css that contains only the line
Quote:
shoppingcart {display:block}

Tested, first part of kuroi's suggestion works fine, second part re creating
contact_us.css with relevant command, does not for me.
:no:

26 Aug 2006, 9:30 AM
#9
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Show/Hide sideboxes based on page

Could be that you've replicated my typo. The line in the contact_us.css file should be > #shoppingcart {display:block}

2 Sep 2006, 12:23 PM
#10
svanis avatar

svanis

Zen Follower

Join Date:
May 2005
Location:
Sweden
Posts:
145
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Hey guys!

This thread feels a bit overkill when it comes to me.

What I wan't is for the reviews sidebox to appear only on the product info page just like tell a friend and manufacturer info.

All help is appreciated..

2 Sep 2006, 1:26 PM
#11
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

You could add a trigger to the reviews sidebox that it only displays if there is a products_id defined ...

However ... on the product _info pages the review sidebox is showing reviews just for the given product and if there are no reviews it shows write a review ...

Is that what you are wanting?

2 Sep 2006, 2:56 PM
#12
svanis avatar

svanis

Zen Follower

Join Date:
May 2005
Location:
Sweden
Posts:
145
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

That is exactly what I want.. :D

2 Sep 2006, 3:08 PM
#13
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Show/Hide sideboxes based on page

Look at the other sideboxes and many have a setting for when to show the sidebox, example, /includes/modules/sideboxes/featured.php uses:

// test if box should display
  $show_featured= true;

Then there is an IF statement surrounding the whole content that starts with:

  if ($show_featured == true) {

You would make something similar where the IF would test for the existance of the products_id ... if > 0 set the show to true ... if <= 0 set the show to false ...

Now it only shows the reviews sidebox when there is a products_id and that only exists when on the product _info page ...

2 Sep 2006, 5:19 PM
#14
svanis avatar

svanis

Zen Follower

Join Date:
May 2005
Location:
Sweden
Posts:
145
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Thank you Linda!

It was a little bit to do but now it seems to work just fine.. :D

If anyone is interested, this is what I did:
I inserted this

  $show_review= false;

  if (isset($_GET['products_id']) and zen_products_id_valid($_GET['products_id'])) {
    if (!($_GET['main_page']==FILENAME_REVIEWS)) $show_review = true;
  }
  if ($show_review == true) {

above

  $review_status = " and r.status = 1 ";

and finished it of with a

}

before```
?>


It's possible this isn't the way to do it but hey! It worked! :P
9 Oct 2006, 2:19 AM
#15
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Okay...I'm totally confused (as usual :P ).

I have the Quick Order mod installed and I want to turn off all the sideboxes for this page only.

What do I need to do to accomplish this?

I did it on my 1.2.7 cart by creating an override tpl_main_page.php file in my quick_order folder, BUT the older file looks nothing like my new file and I can't figure out what I need to change.

So far, I made a copy of the tpl_main_page.php file and put it in my custom templates. But everything I've tried to 'un-comment' has caused a page error. :unsure:

9 Oct 2006, 2:23 AM
#16
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,513
Plugin Contributions:
177

Re: Show/Hide sideboxes based on page

Boggled:

I have the Quick Order mod installed and I want to turn off all the sideboxes for this page only.

What do I need to do to accomplish this?

...

So far, I made a copy of the tpl_main_page.php file and put it in my custom templates.

add this:$flag_disable_left = true; $flag_disable_right = true;right above this:```
$header_template = 'tpl_header.php';
$footer_template = 'tpl_footer.php';

9 Oct 2006, 2:29 AM
#17
boggled avatar

boggled

Zen Follower

Join Date:
Mar 2006
Location:
Tennessee
Posts:
286
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

PERFECT!! Now I can link directly from the description of my eBay auction to my Quick Order page. :smile:

DrByte you are the best! :thumbsup:

1 Mar 2007, 5:02 PM
#18
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

I see that this thread is from early October, at least a version or two back. In viewing the tpl_main_page.php it seems that the capability of commenting out sideboxes is built it.

However, I'm having a difficult time getting things set properly so as to not disrupt other pages. What I would like to do is turn off the sideboxes on the homepage only. Can anyone tell me what the procedure is?

Thanks so much!!

Tim

1 Mar 2007, 5:15 PM
#19
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Show/Hide sideboxes based on page

Create an over-ride file for common/tpl_main_page.php and insert the following block of code at around line 45-46> if ($this_is_home_page == true) {

$flag_disable_left = true;
$flag_disable_right = true;

}

1 Mar 2007, 5:59 PM
#20
meltdown avatar

meltdown

Totally Zenned

Join Date:
Jun 2006
Location:
My family and I live in Brighton, England
Posts:
947
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

kuroi:

Create an over-ride file for common/tpl_main_page.php and insert the following block of code at around line 45-46

That did it!! Thanks Kuroi :smile: