Forums / Templates, Stylesheets, Page Layout / Header change according to category

Header change according to category

Locked

Started by cregy on 23 Feb 2007, 4:38 PM · Views: 8,670

Results 1 to 20 of 32
This thread is locked. New replies are disabled.
23 Feb 2007, 4:38 PM
#1
cregy avatar

cregy

New Zenner

Join Date:
Oct 2006
Location:
Lostwithiel, Cornwall
Posts:
69
Plugin Contributions:
0

Header change according to category

Hi

Is it possible to change the header according to category please? i.e. If the header has a man with a kilt in on the front page, when I click on the category kilts woman, can I change the header image to a woman in a kilt please?

Also how do I change the size of category images on the home page?

Many thanks.

Rich

23 Feb 2007, 10:49 PM
#2
crazy_chris avatar

crazy_chris

New Zenner

Join Date:
Feb 2007
Location:
Vienna
Posts:
38
Plugin Contributions:
0

Re: Header change according to category

sure.

i'd suggest to connect the header-image to the cPath (it's easy).

basics
each category has it's own cPath. the first step is to write down which categories you want to use and their cPath. eg klick on the category "kilts woman" and write down the cPath from the addressbar.

do it
like zencart does it by default, you should set the header-image in the css file like that:

#logoWrapper{
    background-image: url(../images/header_bg.jpg);
    background-repeat: repeat-x;
    background-color: #ffffff;
    height:75px;
    }
```now, we connect the css with the cPath's. 

create one logoWrapper for each possible logo, and add a '_' and the cPath after "#logoWrapper" like that example: 
(assumed, the category "women kilts" has the cPath 1, and "mens kilts" is 2)
```php
#logoWrapper_1 {
    background-image: url(../images/header_bg_women_kilt.jpg);
    background-repeat: repeat-x;
    background-color: #ffffff;
    height:75px;
    }
#logoWrapper_2 {
     background-image: url(../images/header_bg_men_kilt.jpg);
     background-repeat: repeat-x;
     background-color: #ffffff;
     height:75px;
     }
```now we come to the file "**/includes/templates/your_template_dir/common/tpl_header.php**"1. find the line *<div id="logoWrapper">* (line 70 here)
2. just before that line, we specify, which cpaths we want to have the logo changed. 
add that code before the <div> and modify the $logo_cpath to your needs (here we allow cpath 1 and 2 to change the logo):```php
<?php
unset($logo_cpath);
$logo_cpath[] = "1";
$logo_cpath[] = "2";
/* add as many $logo_cpath[] = ...; as you want */
?>
  1. replace *<div id="logoWrapper"> with that:
    *```php
<div id="logoWrapper<?php if (array_search($_REQUEST['cPath'], $logo_cpath)) { echo '_' . $_REQUEST['cPath']; } ?>"> ```**thats it!**

may sound tricky, but is completely easy. try it out!

26 Feb 2007, 10:56 AM
#3
cregy avatar

cregy

New Zenner

Join Date:
Oct 2006
Location:
Lostwithiel, Cornwall
Posts:
69
Plugin Contributions:
0

Re: Header change according to category

Hi

Absolutely brilliant and totally easy - thanks to you.

Take a look at the test run:
http://zencart.cregy.co.uk/

Rich

16 Mar 2007, 11:37 AM
#4
cregy avatar

cregy

New Zenner

Join Date:
Oct 2006
Location:
Lostwithiel, Cornwall
Posts:
69
Plugin Contributions:
0

Re: Header change according to category

Hi Chris

crazy_chris:

sure.

i'd suggest to connect the header-image to the cPath (it's easy).

may sound tricky, but is completely easy. try it out!

Thanks for this and it works perfectly. Is it possible to do it with a non-cpath item please?

http://palomablanca.org.uk/

Thanks

Rich

31 Mar 2007, 5:59 PM
#5
dale_thomas avatar

dale_thomas

New Zenner

Join Date:
Feb 2007
Posts:
24
Plugin Contributions:
0

Re: Header change according to category

I want to do this but I need to use a flash file. Can this be done through CSS?

One thought I had was to have a hard coded header file for each category. Anyone know of an easy way to the above code changes with a header file?

31 Mar 2007, 6:12 PM
#6
cregy avatar

cregy

New Zenner

Join Date:
Oct 2006
Location:
Lostwithiel, Cornwall
Posts:
69
Plugin Contributions:
0

Re: Header change according to category

Hi

I am not sure I understand the question.

  1. Do you want the header to be a flash file?
  2. Do you want the header to rotate flash files?

Thanks

Rich

31 Mar 2007, 6:21 PM
#7
dale_thomas avatar

dale_thomas

New Zenner

Join Date:
Feb 2007
Posts:
24
Plugin Contributions:
0

Re: Header change according to category

I want to display a flash file in the header and rotate it out depending on the category.

Sorry if I wasn't clear.

31 Mar 2007, 7:00 PM
#8
cregy avatar

cregy

New Zenner

Join Date:
Oct 2006
Location:
Lostwithiel, Cornwall
Posts:
69
Plugin Contributions:
0

Re: Header change according to category

Hi Dale

I'm not sure that it is possible with the above code but there might be another way to do it. I have asked the question on another forum and I'll continue to look and try myself.

Rich

26 Apr 2007, 8:26 AM
#9
svanis avatar

svanis

Zen Follower

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

Re: Header change according to category

Wonderful mod!

One little issue though, I need the header to be inherited to my subcategories.
Otherwise I would have to manually add approx. 200 sub and sub sub categories to my 5 top categories.

Anyone with a nice solution?

Also, I met some resistance with one of my categories, everything looked fine in the code and all I had to do was to create a new category to get a new id.
The non-working id was "10", has anyone noticed this issue and have a good answer on what caused it?

10 Jun 2007, 6:45 AM
#10
robbyn7 avatar

robbyn7

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
0

Re: Header change according to category

I must be missing something. I thought followed these instructions to the T several times and still can't get my new header to show on the corresponding category. The first thing I did was added the logowrapper and cpath to my stylesheet. See my example below:
#logoWrapper_14 {
background-image: urlCOLOR=#007700;
background-repeat: repeat-x;
background-color: #ffffff;
height:160px;
}
[/COLOR]
Then I followed these instructions:
<?php unset($logo_cpath); $logo_cpath[] = "14"; /* add as many $logo_cpath[] = ...; as you want */ ?>

And finally I replaced the divd logowrapper:
<div id="logoWrapper<?php if (array_search($_REQUEST['cPath'], $logo_cpath)) { echo '_' . $_REQUEST['cPath']; } ?>">

I'm using the Purpleshades template and the latest version 1.3.7. Am I missing something?

Thanks for any help.

10 Jun 2007, 10:57 AM
#11
testuser avatar

testuser

Inactive

Join Date:
Oct 2004
Location:
Houston, TX
Posts:
792
Plugin Contributions:
0

Re: Header change according to category

There's a global that changes according to the page your on:

$body_id

This can be used in various ways...

View the Academe Template here, and you will see the banner is displayed on the index page but removed for every other page. Now, I could change this if i needed to depending on the page by utilizing this $body_id.

Examples:

To make the banner, seen on the homepage of the Academe demo, appear only on the main page ... the code is as follows:

<?php
    if($body_id == 'index' && $cPath == ''){
  if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }}
?>

This could also be used to disable the right column on your category page that has the id (for example) 3:

 if ($current_page_base == 'index' && $cPath == '3') {
   $flag_disable_right = true;}

Colin @ iChoze Internet Solutions
Zen Cart Stuff powered by Zen Cart
http://zen-cart-templates.ichoze.net

10 Jun 2007, 1:17 PM
#12
robbyn7 avatar

robbyn7

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
0

Re: Header change according to category

Thanks for the reply,

I'm not understanding how I would modify the code if I'm trying to change the header and not a banner? And is this only done to the tpl_header.php file? No changes need to be made to the stylesheet? Thanks.

11 Jun 2007, 6:58 PM
#13
robbyn7 avatar

robbyn7

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
0

Re: Header change according to category

Is there a simple solution to this?

22 Aug 2007, 6:15 PM
#14
robbyn7 avatar

robbyn7

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
0

Re: Header change according to category

Just wanted to know if there's a simple way to have different headers on each page. For instance, shirts would have its on header and pants would have its own header. Is there an easy way to do this?

Thanks for your help.

Link to my store: http://www.foxxydiva.com/fashions

22 Aug 2007, 6:28 PM
#15
testuser avatar

testuser

Inactive

Join Date:
Oct 2004
Location:
Houston, TX
Posts:
792
Plugin Contributions:
0

Re: Header change according to category

Robbyn7:

Just wanted to know if there's a simple way to have different headers on each page. For instance, shirts would have its on header and pants would have its own header. Is there an easy way to do this?

Thanks for your help.

Link to my store: http://www.foxxydiva.com/fashions

You could dynamically change the #flashcontent ID in your header file to be different based on your category id, something like #flashcontent1, #flashcontent2.

Maybe an ID like #flashcontentbottoms or #flashcontentsale would better suit your site, just depends on your organization.

You'd then have corresponding styles in your stylesheet for different bg's. And I just realized your a flash header :lamo: ... Ok so ... forget the stylesheet stuff, forget changing the ID of that div ... you'd just have to load a different SWF file (based on your category id still).

Maybe I answered two questions there, iono :bangin:

Colin @ iChoze Internet Solutions
Zen Cart Stuff powered by Zen Cart
http://zen-cart-templates.ichoze.net

22 Aug 2007, 6:37 PM
#16
testuser avatar

testuser

Inactive

Join Date:
Oct 2004
Location:
Houston, TX
Posts:
792
Plugin Contributions:
0

Re: Header change according to category

testuser:

<?php if($body_id == 'index' && $cPath == ''){ if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) { if ($banner->RecordCount() > 0) { ?> <div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div> <?php } }} ?> ```

UPDATE OF FIRST POST:

To only make something show on the homepage (banner in this example):

<?php
    if($this_is_home_page){
  if (SHOW_BANNERS_GROUP_SET3 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET3)) {
    if ($banner->RecordCount() > 0) {
?>
<div id="bannerThree" class="banners"><?php echo zen_display_banner('static', $banner); ?></div>
<?php
    }
  }}
?>

If you'd like it to not show, change $this_is_home_page to !$this_is_home_page .

Colin @ iChoze Internet Solutions
Zen Cart Stuff powered by Zen Cart
http://zen-cart-templates.ichoze.net

23 Aug 2007, 5:37 PM
#17
robbyn7 avatar

robbyn7

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
0

Re: Header change according to category

Thanks for the reply testuser. The reason I went with the flash logo was because I couldn't figure out how to have different headers on each page. Hmm....I've tried the previous resolution but that didn't work for me. Maybe I'm just not understanding. I'll check out your solution and load a different SWF file.
Thanks for your help.

14 Jan 2008, 1:25 PM
#18
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Header change according to category

Very very nice....

Works great...but only the cPath=1 won't work for me...it has the image of #logoWrapper not of the #logoWrapper_1

The other images of cPath=2, cPath=3, cPath=4 works great

Why doesn't cPath=1 work for me?

15 Jan 2008, 3:42 AM
#19
testuser avatar

testuser

Inactive

Join Date:
Oct 2004
Location:
Houston, TX
Posts:
792
Plugin Contributions:
0

Re: Header change according to category

raimond:

Very very nice....

Works great...but only the cPath=1 won't work for me...it has the image of #logoWrapper not of the #logoWrapper_1

The other images of cPath=2, cPath=3, cPath=4 works great

Why doesn't cPath=1 work for me?

Do you have a style defined correctly? Can you post the file you've edited?

Colin @ iChoze Internet Solutions
Zen Cart Stuff powered by Zen Cart
http://zen-cart-templates.ichoze.net

15 Jan 2008, 8:45 AM
#20
raimond avatar

raimond

Zen Follower

Join Date:
Jul 2004
Location:
The Netherlands, Wierden
Posts:
423
Plugin Contributions:
0

Re: Header change according to category

testuser:

Do you have a style defined correctly? Can you post the file you've edited?

This is the section in the stylesheet.css

#logoWrapper {
    background: url(../images/header_bg.jpg) no-repeat top right;
    border-bottom: 1px solid white;
    height: 197px;
    margin: 0px;
    padding: 0px;
    }

#logoWrapper_1 {
    background: url(../images/header_bg_jeans.jpg) no-repeat top right;
    border-bottom: 1px solid white;
    height: 197px;
    margin: 0px;
    }
#logoWrapper_2{
    background: url(../images/header_bg_t-shirts.jpg) no-repeat top right;
    border-bottom: 1px solid white;
    height: 197px;
    margin: 0px;
    }

#logoWrapper_3{
    background: url(../images/header_bg_shirt.jpg) no-repeat top right;
    border-bottom: 1px solid white;
    height: 197px;
    margin: 0px;
    }
```and this is the section in the tpl_header.php
<?php unset($logo_cpath); $logo_cpath[] = "1"; $logo_cpath[] = "2"; $logo_cpath[] = "3"; $logo_cpath[] = "2"; /* add as many $logo_cpath[] = ...; as you want */ ?> <!--bof-branding display--> <div id="logoWrapper<?php if (array_search($_REQUEST['cPath'], $logo_cpath)) { echo '_' . $_REQUEST['cPath']; } ?>"> <div id="logo"><?php echo '<a href="' . HTTP_SERVER . DIR_WS_CATALOG . '">' . zen_image($template->get_template_dir(HEADER_LOGO_IMAGE, DIR_WS_TEMPLATE, $current_page_base,'images'). '/' . HEADER_LOGO_IMAGE, HEADER_ALT_TEXT) . '</a>'; ?></div> <?php if (HEADER_SALES_TEXT != '' || (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2))) { ?> <div id="taglineWrapper"> <?php if (HEADER_SALES_TEXT != '') { ?> <div id="tagline"><?php echo HEADER_SALES_TEXT;?></div> <?php } ?> <?php if (SHOW_BANNERS_GROUP_SET2 != '' && $banner = zen_banner_exists('dynamic', SHOW_BANNERS_GROUP_SET2)) { if ($banner->RecordCount() > 0) { ?> <div id="bannerTwo" class="banners"><?php echo zen_display_banner('static', $banner);?></div> <?php } } ?> </div> <?php } // no HEADER_SALES_TEXT or SHOW_BANNERS_GROUP_SET2 ?> </div> <!--eof-branding display--> ```