Elxis CMS Forum

Extensions => Templates => Topic started by: babis1 on October 06, 2010, 10:18:51

Title: changing bg image in div every time you call different menu link
Post by: babis1 on October 06, 2010, 10:18:51
i have a <div id="header"> with css background: url(../images/logo.jpg) no-repeat top; now i need to change the image every time when i call different menu links-items (in pe 5 different links-items)................................. ??? thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Title: Re: changing bg image in div every time you call different menu link
Post by: datahell on October 06, 2010, 18:35:00
Replace this: <div id="header">

with something like this:

<?php
switch ($Itemid) {
   case 2: $sfx = '-1'; break;
   case 7: $sfx = '-2'; break;
   case 19: $sfx = '-3'; break;
   default: $sfx = ''; break;
}
?>
<div class="header<?php echo $sfx; ?>">

Now, on your template's css file add these classes (off course change the CSS to you want):

.header-1 {background-color: #ff9900; }
.header-2 {background-color: #ff0000; }
.header-3 {background-color: yellow; }
.header {background-color: #ddd; }

2, 7 and 19 are sample Itemid's. Put your own before the "default" statement. You can give any suffix you want, I used "-1, -2, -3" as a sample. You can also add any number of them. The "header" class is the default one.

Recommendation: Do not use ID everywhere. Id should be used on very special elements. Use CSS classes instead.
Title: Re: changing bg image in div every time you call different menu link
Post by: babis1 on October 06, 2010, 18:39:48
<?php
switch ($Itemid) {
   case 2: $sfx = '-1'; break;
   case 7: $sfx = '-2'; break;
   case 19: $sfx = '-3'; break;
   default: $sfx = ''; break;
}
?>


that code goes before </head> ?
Title: Re: changing bg image in div every time you call different menu link
Post by: webgift on October 06, 2010, 18:41:43
Just before the <div class="header<?php echo $sfx; ?>">  ;)
Title: Re: changing bg image in div every time you call different menu link
Post by: babis1 on October 06, 2010, 18:42:22
ok thanks a lot i go to try it  ;D ;D ;D
--------after----------------------------
ok it works fine !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! i need it only for 5 items, because there i cant have module position
Title: Re: changing bg image in div every time you call different menu link
Post by: babis1 on October 20, 2010, 10:40:54
ok another one if i want to use the same img in more than one items pe case 2,29,30.....
Title: Re: changing bg image in div every time you call different menu link
Post by: webgift on October 20, 2010, 11:45:17
<?php
switch ($Itemid) {
   case 2: $sfx = '-5'; break;
   case 29: $sfx = '-5'; break;
   case 30: $sfx = '-5'; break;
   default: $sfx = ''; break;
}
?>
<div class="header<?php echo $sfx; ?>">

css file:
.header-5 {background: #ff9900 url(../images/my_image.jpg) no-repeat 0 0;  }
Title: Re: changing bg image in div every time you call different menu link
Post by: Amigamerlin on October 20, 2010, 12:00:17
This board is simply fantastic !!! A lot of learning thing here. Thank you you all for all the time you reserve to ELXIS !!
Ciao
Title: Re: changing bg image in div every time you call different menu link
Post by: ArXoS on November 04, 2010, 00:01:45
 :o :o :o bookmarked  ;D
Title: Re: changing bg image in div every time you call different menu link
Post by: ahmet on January 05, 2012, 20:05:46
book marked also..
thats why we have to know php or java
the power of php..