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

Show/Hide sideboxes based on page

Views: 43,781

Results 101 to 120 of 189
9 Apr 2010, 5:47 PM
#101
monkeyjr47906 avatar

monkeyjr47906

New Zenner

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

Show/Hide sideboxes based on page

Hi - I tried searching through the posts but I can't find an answer.

In my site I have some pages with the right column on and others with the left turned on.

I have a sidebox (newsletter subscribe) that I would like to appear on ALL pages. Since you need to specify L or R in the layout controller I'm stuck, is there a way to show the sidebox on left AND right columns?

I guess I could create a duplicate sidebox, but that seems like a nightmare.

1.3.8

10 Apr 2010, 12:33 AM
#102
gjh42 avatar

gjh42

Black Belt

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

Re: Show/Hide sideboxes based on page

I don't think there is a way short of deep coding changes to have the sidebox show on both sides, but I have to question how good it is to design a site where the sidebar jumps from left to right. Do you have both sidebars sometimes? Or is there a pressing need to show different sidebars on different pages? (Different sideboxes, sure.)

11 Apr 2010, 1:24 AM
#103
monkeyjr47906 avatar

monkeyjr47906

New Zenner

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

Re: Show/Hide sideboxes based on page

gjh42:

I don't think there is a way short of deep coding changes to have the sidebox show on both sides, but I have to question how good it is to design a site where the sidebar jumps from left to right. Do you have both sidebars sometimes? Or is there a pressing need to show different sidebars on different pages? (Different sideboxes, sure.)

In some areas of the site I use the left column for additional navigation, on the product pages I use the right column for additional downloadable information (whitepapers, etc.).

Well I've done it before - make two copies of the same sidebox. The problem in this situation I want to do it with the newsletter subscription mod and I'm a little concerned about the code. I wanted to see if there was a simple way to do it before I start digging into this stuff.

17 Apr 2010, 9:39 AM
#104
valery avatar

valery

New Zenner

Join Date:
Apr 2010
Posts:
3
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Hi, I want hide sideboxes on the products pages... what I can do?

17 Apr 2010, 12:26 PM
#105
gjh42 avatar

gjh42

Black Belt

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

Re: Show/Hide sideboxes based on page

Do you want to hide just certain sideboxes, or the whole sidebar? The solution will use different files depending on your need.

3 May 2010, 5:54 PM
#106
jackie_taferner avatar

jackie_taferner

Totally Zenned

Join Date:
Jun 2009
Location:
Orange County, California
Posts:
547
Plugin Contributions:
3

Re: Show/Hide sideboxes based on page

This thread might be useful to you: http://www.zen-cart.com/forum/showthread.php?t=44160

It shows some code specific to Product Listing pages, but the general idea is the same if you're looking to block sideboxes based on specific page ID#.

18 May 2010, 7:39 AM
#107
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Hi I've had a read through this very helpful post and got my head around the idea (I think) I have my site set to show no sideboxes while going through check out by using the flags on the main template. But I want to show a particular box when just going through checkout. This box will allow my customers to check delivery times and the returns policy while going through check out if they haven't already Can I override the global settings with code in the side box?

I'm guessing I need to put a conditional statement somewhere, but I'm not a php coder so I don't really have an idea of where to start.

Any help will be greatly appreciated. Please let me know if I've not explained myself clearly.

Thanks

Kerrie

18 May 2010, 7:58 AM
#108
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

To do this, you will need to turn the column on and control the boxes individually. Turning one on only in the checkout and the others off when you are there.

There's an example of control over the display of individual boxes for the homepage in https://www.zen-cart.com/tutorials/index.php?article=270.

What you want to do would be similar, except that your conditions would be more like those you were using to control the columns.

18 May 2010, 8:21 AM
#109
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

thanks for your reply, i've commented out the global flags for now.

I tried to implement the code shown in the tutorial and it works for my home page but I need to show it on the check out pages, so I amended the code on the module to this```php
if ($this_is_shopping_cart,$this_is_login,$this_is_checkout_shipping,$this_is_checkout_shipping_address,$this_is_checkout_payment,$this_is_checkout_confirmation,$this_is_checkout_success) {
$show_blank_sidebox10 = true;
} else {
$show_blank_sidebox10 = false;
}


But it doens't work. I've literally gone from the template but I'm sure it can be written better.

Any ideas?

Once I know how to do this one, I'll be able to do it for the other side boxes.
18 May 2010, 8:24 AM
#110
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

You need to use a condition more like the if (in_array(...)) statement that you were using for the column, but in the individual box modules.

18 May 2010, 8:34 AM
#111
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

thanks again

I've now got this and it still doesn't work.```php
if (in_array($current_page_base,explode(",",'shopping_cart,login,checkout_shipping,checkout_shipping_address,checkout_payment,checkout_confirmation,checkout_success')) )
{
$show_featured = true;
}else {
$show_blank_sidebox10 = false;
}

18 May 2010, 8:44 AM
#112
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

It's ok, I just realised my mistake, it works now, so thank you for your help, now to disable to the boxes on those pages :)

18 May 2010, 9:07 AM
#113
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

I'm still having problems

I'm trying to get it so the reviews side box doesn't show on any of the checkout pages so I reversed the code slighty, but it doens't work```php
if (in_array($current_page_base,explode(",",'shopping_cart,login,checkout_shipping,checkout_shipping_address,checkout_payment,checkout_confirmation,checkout_success')) )
{
$show_review_status = false;
}else {
$show_review_status = true;
}


any pointers?
18 May 2010, 11:14 AM
#114
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

I want to remove the sides boxes for reviews, banner, shopping cart and ezpages from the checkout pages but they have a different format to the other side boxes that I've done.

Whwn you get a sec can you give me some pointers. I'd hoped they all have a variation of the line ```php
$show_featured= true;

but I can't find it :(
18 May 2010, 12:48 PM
#115
gjh42 avatar

gjh42

Black Belt

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

Re: Show/Hide sideboxes based on page

Not all sideboxes have the show/if code in place to do the testing with. If you don't see it, you can add it, customizing to the sidebox and making sure you close the if(){ with a } at the bottom of the executable code block (in <?php } ?> tags if necessary).

18 May 2010, 1:29 PM
#116
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

thanks, I've put the following code on the shopping cart mod (using the template override) ```php
if (in_array($current_page_base,explode(",",'shopping_cart,login,checkout_shipping,checkout_shipping_address,checkout_payment,checkout_confirmation,checkout_success')) )
{
$show_shopping_cart = false;
}else {
$show_shopping_cart = true;
}


But it doesn't make a difference
18 May 2010, 1:49 PM
#117
gjh42 avatar

gjh42

Black Belt

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

Re: Show/Hide sideboxes based on page

You also need the display test around the code:```php
if ($show_shopping_cart == true) {

//output code

}

18 May 2010, 2:20 PM
#118
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

sorry I'm really confused as I barely know a thing about php, what should this could look like?

18 May 2010, 2:49 PM
#119
gjh42 avatar

gjh42

Black Belt

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

Re: Show/Hide sideboxes based on page

Some sideboxes have the conditional for showing the sidebox based on $show_xxx == true, as in my post above. You want to have that surrounding the code in the sidebox module file in addition to the code you posted.```php
if (in_array($current_page_base,explode(",",'shopping_cart,login,checkout_shipping,checkout_shipping_address,checkout_payment,checkout_confirmation,checkout_success')) )
{
$show_shopping_cart = false;
}else {
$show_shopping_cart = true;
}

if ($show_shopping_cart == true) {

//the existing output code in the file

}

18 May 2010, 3:00 PM
#120
kezan98 avatar

kezan98

Zen Follower

Join Date:
Nov 2007
Location:
UK
Posts:
98
Plugin Contributions:
0

Re: Show/Hide sideboxes based on page

Hi thanks for that. it didn't work, so I'm posting the entire code in case you can spot where I've gone wrong (if you've got the time) ```php

<?php /** * shopping_cart sidebox - displays contents of customer's shopping cart. Also shows GV balance, if any. * * @package templateSystem * @copyright Copyright 2003-2007 Zen Cart Development Team * @copyright Portions Copyright 2003 osCommerce * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0 * @version $Id: shopping_cart.php 7437 2007-11-16 21:33:16Z drbyte $ */ if (in_array($current_page_base,explode(",",'shopping_cart,login,checkout_shipping,checkout_shipping_address,checkout_payment,checkout_confirmation,checkout_success')) ) { $show_shopping_cart = false; }else { $show_shopping_cart = true; } if ($show_shopping_cart == true) { switch (true) { case (SHOW_SHOPPING_CART_BOX_STATUS == '0'): $show_shopping_cart_box = true; break; case (SHOW_SHOPPING_CART_BOX_STATUS == '1'): if ($_SESSION['cart']->count_contents() > 0 || (isset($_SESSION['customer_id']) && zen_user_has_gv_account($_SESSION['customer_id']) > 0)) { $show_shopping_cart_box = true; } else { $show_shopping_cart_box = false; } break; case (SHOW_SHOPPING_CART_BOX_STATUS == '2'): if ( ( (isset($_SESSION['cart']) && $_SESSION['cart']->count_contents() > 0) || (isset($_SESSION['customer_id']) && zen_user_has_gv_account($_SESSION['customer_id']) > 0) ) && ($_GET['main_page'] != FILENAME_SHOPPING_CART) ) { $show_shopping_cart_box = true; } else { $show_shopping_cart_box = false; } break; } if ($show_shopping_cart_box == true) { require($template->get_template_dir('tpl_shopping_cart.php',DIR_WS_TEMPLATE, $current_page_base,'sideboxes'). '/tpl_shopping_cart.php'); $title = BOX_HEADING_SHOPPING_CART; $title_link = false; $title_link = FILENAME_SHOPPING_CART; require($template->get_template_dir($column_box_default, DIR_WS_TEMPLATE, $current_page_base,'common') . '/' . $column_box_default); } ?>