Forums / Templates, Stylesheets, Page Layout / Display sidebox only on certain pages

Display sidebox only on certain pages

Views: 3,941

Results 1 to 20 of 25
19 Nov 2011, 9:00 PM
#1
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Display sidebox only on certain pages

I want the something to only display on the home page and the categories pages but not the product list pages. I don't recall seeing a hook like that. Looking at the categories sidebox and the category tree functions, there is some code about that:

box_categories_array[$ii]['has_sub_cat']
```.

I've not been able to figure out how to use that or if can be used for what I'm talking about.

Any ideas?

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

20 Nov 2011, 12:26 AM
#2
drbyte avatar

drbyte

Sensei

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

Re: Display sidebox only on certain pages

Try:

if ($this_is_home_page || $category_depth == 'nested' || $category_depth == 'top') 

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

20 Nov 2011, 12:33 AM
#3
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Display sidebox only on certain pages

beautiful!

Code to put in the tricks box.

Thanks!

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

20 Nov 2011, 12:59 PM
#4
trickobrien avatar

trickobrien

Zen Follower

Join Date:
Jul 2010
Posts:
108
Plugin Contributions:
0

Re: Display sidebox only on certain pages

if ($this_is_home_page || $category_depth == 'nested' || $category_depth == 'top')

What adjustment to this code would be necessary to have sideboxes display only on product list area?

and which file do I add it to?

20 Nov 2011, 1:38 PM
#5
delia avatar

delia

Totally Zenned

Join Date:
May 2006
Location:
Gardiner, Maine
Posts:
2,383
Plugin Contributions:
7

Re: Display sidebox only on certain pages

Based on this logic, add this to your main page template:

if ($category_depth == 'nested')  

by wrapping it around the sideboxes.

If you do this you have to either remove the width from that table cell that is adjusted in admin / layout settings or set the width to nothing- empty. Without testing this out, I can't promise this will work.

But Dr.Byte may have a better suggestion because there are plenty of built in cute little hooks for that kind of thing.

The full-time Zen Cart Guru. WizTech4ZC.com
New template for 2.0 viewable here: 2.0 Demo

21 Nov 2011, 12:10 AM
#6
drbyte avatar

drbyte

Sensei

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

Re: Display sidebox only on certain pages

"top" = top-level categories
"nested" = cats and subcats
"products" = product-listing within said subcat

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

21 Nov 2011, 3:11 AM
#7
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Re: Display sidebox only on certain pages

I have some side boxes that i don't want to show up on the home page but everywhere else how do i do that??

21 Nov 2011, 3:23 AM
#8
drbyte avatar

drbyte

Sensei

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

Re: Display sidebox only on certain pages

!$this_is_home_page

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

21 Nov 2011, 2:17 PM
#9
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Re: Display sidebox only on certain pages

DrByte:

!$this_is_home_page


Thanks for your reply but where do i put it?

 I tried putting it in the top of the sideboxes i don't want to show on the home page and they won't show anywhere and the content of my home page disappears!!
21 Nov 2011, 2:33 PM
#10
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Re: Display sidebox only on certain pages

DrByte:

!$this_is_home_page


> **gazag:**
>
> Thanks for your reply but where do i put it?
> 
>  I tried putting it in the top of the sideboxes i don't want to show on the home page and they won't show anywhere and the content of my home page disappears!!

Don't worry i found it [https://www.zen-cart.com/tutorials/index.php?article=249](https://www.zen-cart.com/tutorials/index.php?article=249) :clap::clap:
21 Nov 2011, 3:15 PM
#11
trickobrien avatar

trickobrien

Zen Follower

Join Date:
Jul 2010
Posts:
108
Plugin Contributions:
0

Re: Display sidebox only on certain pages

Since my products are added directly to top categories,I added the conditional statement

if ($category_depth == 'products') to includes/modules/sideboxes/
just above require ($template->get_template_dir for the sideboxes Im displaying.

And set the sideboxes width to empty in Admin-Config-Layout Settings.

And sideboxes only appear on products area :clap:

However I still have a sidebar on all other areas with -No Picture Available- displaying

The sideboxes I am displaying are Categories and sidebox shopping cart with a checkout button addition

21 Nov 2011, 6:19 PM
#12
gjh42 avatar

gjh42

Black Belt

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

Re: Display sidebox only on certain pages

A more efficient test might be to adapt this thread with the
if ($category_depth == 'products')
test, which will eliminate all categories sidebox processing. This can also be adapted to other sideboxes.

But if you are only displaying any sideboxes (in one sidebar or another) on certain pages, you would best set this in /includes/templates/your_template/common/tpl_main_page.php.
There are instructions for turning off sidebars in the comments. You want

if (!$category_depth == 'products') {
$flag_disable_left = true;
}

Note the !

21 Nov 2011, 8:39 PM
#13
trickobrien avatar

trickobrien

Zen Follower

Join Date:
Jul 2010
Posts:
108
Plugin Contributions:
0

Re: Display sidebox only on certain pages

Got it.

Found my mistake.Had added
if ($category_depth == 'products') above the wrong piece of code on one sidebox.

It works perfect -sideboxes appear exactly where I wanted.

22 Nov 2011, 9:07 AM
#14
trickobrien avatar

trickobrien

Zen Follower

Join Date:
Jul 2010
Posts:
108
Plugin Contributions:
0

Re: Display sidebox only on certain pages

Following the instructions of https://www.zen-cart.com/tutorials/index.php?article=233 and gjh42 to turn off left or right colums,I have created an over-ride file for tpl_main_page.php in my includes/templates/Your_TEMPLATE/common/tpl_main_page.php..

And replaced $flag_disable_right = true;<br />

with if (!$category_depth == 'products') {
$flag_disable_left = true;
}

to disable my right side column- its not having any effect

just wondering what Im doing wrong

I only edited the over ride file

22 Nov 2011, 10:15 AM
#15
drbyte avatar

drbyte

Sensei

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

Re: Display sidebox only on certain pages

If the line you replaced actually had the <br /> on the end of it, then you were editing a comment, not the actual PHP code, which comes later after the comments section.

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

22 Nov 2011, 10:34 AM
#16
trickobrien avatar

trickobrien

Zen Follower

Join Date:
Jul 2010
Posts:
108
Plugin Contributions:
0

Re: Display sidebox only on certain pages

if (in_array($current_page_base,explode(",",'index,shopping_cart,login')) ) {
$flag_disable_right = true;
}

Have this working :) thanks Doc.

No luck with- if (!$category_depth == 'products') {
$flag_disable_left = true;
}

22 Nov 2011, 12:32 PM
#17
gjh42 avatar

gjh42

Black Belt

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

Re: Display sidebox only on certain pages

Post that section of tpl_main_page.php (with a few lines above & below for context) so we can see exactly what you have done.

22 Nov 2011, 1:06 PM
#18
trickobrien avatar

trickobrien

Zen Follower

Join Date:
Jul 2010
Posts:
108
Plugin Contributions:
0

Re: Display sidebox only on certain pages

Yes its official-Im a noob

I was trying to disable the right column

// the following IF statement can be duplicated/modified as needed to set additional flags
  if (in_array($current_page_base,explode(",",'list_pages_to_skip_all_right_sideboxes_on_here,separated_by_commas,and_no_spaces')) ) {
    $flag_disable_right = true;
  }
 if (!$category_depth == 'products') {
 $flag_disable_left = true;
 } 

Yes it works perfectly once i changed left to right

23 Nov 2011, 4:54 PM
#20
gazag avatar

gazag

Zen Follower

Join Date:
Jun 2011
Posts:
195
Plugin Contributions:
0

Re: Display sidebox only on certain pages

I have certain sideboxes that **ONLY **show on the home page and the rest DO NOT SHOW on the homepage.

The sideboxes that show up on the home page don't have any border or heading on them

Is there anyway to make the ones that DO NOT Show on the home page have a border around them when they show up on other pages?

At the moment i have just commented out the border part of the css which makes all sideboxes have no border or header!