Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / disabling the right sidebar only for the product listing

disabling the right sidebar only for the product listing

Views: 4,406

Results 1 to 15 of 15
12 Jul 2010, 9:37 AM
#1
mayilsamy avatar

mayilsamy

New Zenner

Join Date:
Jun 2010
Posts:
20
Plugin Contributions:
0

disabling the right sidebar only for the product listing

Hi,

i knew how to disable the sidebar for the particular page. But my pbm is i want to disable the sidebar only for the product listing(file name is tpl_index_product_list.php not for product_new or product_all). Just image i have a category like the following hierarchy

Shoe->Mens shoe->size->reebok company-

Here when i click the shoe it should show the sidebar upto size category, but when i click the reebok category it will display the products in the nice format. In this place i want to avoid the sidebar..

This is the code i'm using to avoid the sidebar

if(in_array($current_page_base,explode(",",'tell_a_friend,products_all,products_new,contact_us,login,account_history,specials')) )
{
$flag_disable_right = true;
}

In the above condition what name i nee to specify, I already tried product_list, product_listing . But still the sidebar is coming..
Please help on this issue.

12 Jul 2010, 6:41 PM
#2
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: disabling the right sidebar only for the product listing

Do you have a URL we can look at?

13 Jul 2010, 1:54 PM
#4
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: disabling the right sidebar only for the product listing

Do you want to not see the sidebar ONLY on the link you provided, or additionally on indiv product pages as well (like this one)?

In what file did you place the code you quoted?

13 Jul 2010, 2:05 PM
#5
mayilsamy avatar

mayilsamy

New Zenner

Join Date:
Jun 2010
Posts:
20
Plugin Contributions:
0

Re: disabling the right sidebar only for the product listing

Only i want to remove the page i mentioned in the last post. I disabled the sidebars in the tpl_main_page.php by using the code in the first post.

13 Jul 2010, 5:08 PM
#6
blindside avatar

blindside

Totally Zenned

Join Date:
Sep 2004
Posts:
1,237
Plugin Contributions:
1

Re: disabling the right sidebar only for the product listing

Alright, after digging deep into this with Kim, here's the deal...

Displaying categories, at any number of sublevels, does not behave like a "normal" page. Usually, pages have a template in includes/templates/TEMPLATE_NAME/templates and then you can override the stuff in includes/templates/TEMPLATE_NAME/common by creating a templates folder. So for most any other page, I would just tell you to follow instructions in the comments in the tpl_main_page.php header and be done with it...

  • Governs the overall layout of an entire page
  • Normally consisting of a header, left side column. center column. right side column and footer
  • For customizing, this file can be copied to /templates/your_template_dir/pagename
  • example: to override the privacy page
    • make a directory /templates/my_template/privacy
    • copy /templates/templates_defaults/common/tpl_main_page.php to /templates/my_template/privacy/tpl_main_page.php

But like I said, category listings are not normal. They have a separate template, but act as if they are part of the index. Look closer at your example URL...

fomax.us/idglass/index.php?[B]main_page=index[/B]&cPath=90

There are several pages like this that share the index layout. This means that following the override described in the quote above would affect all these shared pages as well (because you'd create /templates/my_template/index/tpl_main_page.php).

If that's as far as the issue went, I could suggest a hackaround. However, you want to show sidebars down to an arbitrary level in the subcategory navigation. That means analyzing the cPath argument in the URL to determine how deep we are. To see what I'm talking about, look at the number after cPath= in these two URL's

  1. http://zc.f10w.com/index.php?main_page=index&cPath=33
  2. http://zc.f10w.com/index.php?main_page=index&cPath=33_34
  3. http://zc.f10w.com/index.php?main_page=index&cPath=33_34_40

The underscore separate's and determines the order of categories. Now our hack has to break that up and analyze how many levels down we're going in order to determine if the sidebar should show up or not. There's code elsewhere in Zen Cart that does this, so we are still in the realm of possibility.

So even at this point, we still have a working -- but very ugly -- hack. However every category must have the exact same number of category levels for this to work. Let's use your example navigation...

Shoe > Mens shoe > Size > Reebok company

It stopped one above the last category, or the third one down. Our hack must now count the levels and turn the sidebar on/off accordingly.

As soon as you introduce a product line with more/less categories, you now have to add even more logic to the hack to track which category we're looking at. The hack now has to ask, "Are we looking at category #33, #34, #105 (etc.)?"

Chances are I made your head spin, in which case I apologize. My head hurts just thinking about coding that out. And my experience as (a) a developer and (b) an admin for a very large ZC installation tells me you're just asking for trouble down the road.

My recommendation is to definitively choose to have sidebars on or off and do it everywhere. It makes your code cleaner, sure, but I say that from a usability perspective too. Users expect similar pages to maintain their layout as they navigate. Dropping a whole section at given level breaks the flow, they think "Wait, somethings different. What is it, what happened? I'm not where I should be..."

A long explanation to a short answer. Hope it helps.

3 Sep 2010, 6:09 PM
#7
get_em_fast avatar

get_em_fast

Totally Zenned

Join Date:
Dec 2006
Location:
Seligman, MO U.S.A.
Posts:
2,072
Plugin Contributions:
1

Re: disabling the right sidebar only for the product listing

I tried this 'hack' as I need to disable the right column for all product pages, but it didnt' seem to work for me. Any suggestions?

3 Sep 2010, 6:23 PM
#8
get_em_fast avatar

get_em_fast

Totally Zenned

Join Date:
Dec 2006
Location:
Seligman, MO U.S.A.
Posts:
2,072
Plugin Contributions:
1

Re: disabling the right sidebar only for the product listing

By the way:

I tried the full URL, the part starting at "index.php?main.........", starting at "index$cpath=....." & just "cpath=24".....all to no avail.

Using ZC 1.3.9b, if that helps.

11 Jul 2011, 6:42 AM
#9
joepixel avatar

joepixel

New Zenner

Join Date:
May 2008
Location:
orlando, florida
Posts:
28
Plugin Contributions:
0

Re: disabling the right sidebar only for the product listing

I realize this thread is a little old but I thought I'd add a solution for this that seemed to work for me.

I added the following line to the top of the templates/tpl_product_info_display.php file:

$flag_disable_right = true;

Pretty simple!

11 Jul 2011, 1:16 PM
#10
dgent avatar

dgent

Totally Zenned

Join Date:
Nov 2009
Location:
UK
Posts:
1,117
Plugin Contributions:
0

Re: disabling the right sidebar only for the product listing

There is an even easier solution, and you can do this for any product, or category, or page you like.

Make a new css file simply containing...

.columnRight { display: none;}

Call it 'norightbox.css' or whatever you like, then call the stylesheet from any product/category description that you like.

12 Jul 2011, 1:30 AM
#11
get_em_fast avatar

get_em_fast

Totally Zenned

Join Date:
Dec 2006
Location:
Seligman, MO U.S.A.
Posts:
2,072
Plugin Contributions:
1

Re: disabling the right sidebar only for the product listing

Yes, but as css only hides it from YOUR view.............it can still be seen and read by browsers, which could leave a person using a 'reader' a little confused...........

dgent:

There is an even easier solution, and you can do this for any product, or category, or page you like.

Make a new css file simply containing...

.columnRight { display: none;}

Call it 'norightbox.css' or whatever you like, then call the stylesheet from any product/category description that you like.

12 Jul 2011, 1:31 AM
#12
get_em_fast avatar

get_em_fast

Totally Zenned

Join Date:
Dec 2006
Location:
Seligman, MO U.S.A.
Posts:
2,072
Plugin Contributions:
1

Re: disabling the right sidebar only for the product listing

OH, Well...............DUH on us, huh? That's why we didn't think of it...............it's just downright TOO simple. :D

joepixel:

I realize this thread is a little old but I thought I'd add a solution for this that seemed to work for me.

I added the following line to the top of the templates/tpl_product_info_display.php file:

$flag_disable_right = true;

Pretty simple!

12 Jul 2011, 5:24 AM
#13
joepixel avatar

joepixel

New Zenner

Join Date:
May 2008
Location:
orlando, florida
Posts:
28
Plugin Contributions:
0

Re: disabling the right sidebar only for the product listing

Get Em Fast:

OH, Well...............DUH on us, huh? That's why we didn't think of it...............it's just downright TOO simple. :D
I like simple! :) And, you get the added benefit of a little faster load time since this section is not called.

12 Jan 2018, 4:47 AM
#14
ttfan avatar

ttfan

Zen Follower

Join Date:
Jul 2010
Location:
Australia
Posts:
231
Plugin Contributions:
0

Re: disabling the right sidebar only for the product listing

joepixel:

I realize this thread is a little old but I thought I'd add a solution for this that seemed to work for me.

I added the following line to the top of the templates/tpl_product_info_display.php file:

$flag_disable_right = true;

Pretty simple!
Great solution!

What file would you need to edit to disable the right sidebar only for Categories? Disabling it for categories means I can list more products per page, and it leaves more room for the category description. Thanks guys!

12 Jan 2018, 4:11 PM
#15
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,960
Plugin Contributions:
8

Re: disabling the right sidebar only for the product listing

rather than editing each template file individually, i would edit

includes/templates/YOUR_TEMPLATE/common/tpl_main_page.php

and you can add all of your code in 1 place. for example:

	if ($current_page_base == 'index' and $_GET['cPath'] != '' ) {
		$flag_disable_left = true;
		$flag_disable_right = true;
	}

for product info page you can add:

	if ($current_page_base == 'product_info' ) {
		$flag_disable_left = true;
		$flag_disable_right = true;
	}

for multiple pages where you want to do the same thing, you can use the following if statement:

if (in_array($current_page_base,explode(",",'products_new,products_all,specials,featured_products,checkout_shipping_address,checkout_payment'))) {
     /// do whatever you want here
}

the oyster is your world.... or something like that....