Zen Cart Logo
Forums / Templates, Stylesheets, Page Layout / Custom Banner for each product category

Custom Banner for each product category

Locked

Views: 2,507

Results 1 to 9 of 9
This thread is locked. New replies are disabled.
2 Dec 2009, 5:58 AM
#1
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Custom Banner for each product category

Hi, Ive searched the forums here but couldnt find an answer; is there a way to show a custom banner depending on the product category currently being viewed?

I was reading this thread; http://www.zen-cart.com/forum/showthread.php?t=129955&highlight=Custom+banner+category%3F

And its close to what I want.

Strictly speaking, i dont need a banner, but I want a large-sized image (not a thumbnail) to be at the top of the main column for each product category.

Any thoughts on the best way to do this?

Going by the thread referenced above, id need to set up some php if statements. If anyone can help with the syntax that would be great thanks.

Thanks,

Scott.

2 Dec 2009, 8:44 AM
#2
niccol avatar

niccol

Totally Zenned

Join Date:
Apr 2009
Posts:
2,138
Plugin Contributions:
1

Re: Custom Banner for each product category

One way to approach this would be to use the ability Zen Cart has to apply a different css file to each category. The instruction about how to do this are in a readme file in the css folder of the default template and you can search the forum for further information.

A downside of that would be that the image would be a background so would not be linkable.

If you want to create an image that links then you would need to get stuck into a bit of php coding which is not too difficult.

Or alternately someone may have done something similar before but I haven't seen it on the forums.

2 Dec 2009, 8:49 AM
#3
kobra avatar

kobra

Black Belt

Join Date:
Aug 2005
Location:
Arizona
Posts:
31,500
Plugin Contributions:
4

Re: Custom Banner for each product category

Settle on a size and set it in the admin-config - images

2 Dec 2009, 9:10 AM
#4
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: Custom Banner for each product category

Hi Guys, thanks for the reply. THe image needs to be an exact size as the right col and the header ######## up to it.

I think ill need to build a PHP [If] and [Else] statement to do it.

Luckily, I have a programmer friend to help me, just wanted to check here first to see if anyone had done it first.

Cheers,

Scott.

3 Dec 2009, 11:58 AM
#5
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: Custom Banner for each product category

In the interest of sharing, I figured out how to display a different image depending on which category is currently being viewed;

<?php if ( (int)$cPath  == "1" ) {
echo '<img src="images/a.jpg">'; 
}
elseif ( (int)$cPath  == "2" ) {
echo '<img src="images/b.jpg">'; 
}
else {
echo '<img src="images/c.jpg">'; 

}
?>

cPath 1 is category one, cPath2 is category two and so on. You can keep building this "if" statement for as many categories that you have.

The last "else" is to display a default image for any page outside of a category, e.g; privacy page, or shipping page etc.

I know this would be elementary stuff for a php coder, but i thought id post it in case someone is looking for a fix like this.

Cheers,

Scott.

3 Dec 2009, 12:01 PM
#6
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: Custom Banner for each product category

P.S. this code was built to display in the main center column of the template; tpl_main_page.php

I put it right after the breadcrumb code so that my different images are always at the top of the page.

3 Dec 2009, 4:31 PM
#7
gjh42 avatar

gjh42

Black Belt

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

Re: Custom Banner for each product category

Hi guys, just found this thread.
Smart Backgrounds is built to do what you want; in some situations (lots of variations) it is easier to manage, and in other situations (fewer variations) the c_##.css method is easier.

Smart Backgrounds can be modified to switch foreground images or any other page-sensitive task as well, based on the existence of a relevant image file (described in the readme). I have a new version of it (3.0) that makes this even easier. I haven't submitted it yet, so I will attach it here until it is publicly available. I believe it is completely functional, but let me know if there is any problem.

4 Dec 2009, 12:43 AM
#8
scott_c avatar

scott_c

Zen Follower

Join Date:
Dec 2009
Posts:
236
Plugin Contributions:
0

Re: Custom Banner for each product category

Thanks Glenn, i'll check this out.

9 Feb 2010, 3:45 AM
#9
gjh42 avatar

gjh42

Black Belt

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

Re: Custom Banner for each product category

Zip attachment moved to Smart Backgrounds support thread, pending activation in Free Addons.