Elxis CMS Forum
Extensions => Templates => Topic started 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 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
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.
-
<?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> ?
-
Just before the <div class="header<?php echo $sfx; ?>"> ;)
-
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
-
ok another one if i want to use the same img in more than one items pe case 2,29,30.....
-
<?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; }
-
This board is simply fantastic !!! A lot of learning thing here. Thank you you all for all the time you reserve to ELXIS !!
Ciao
-
:o :o :o bookmarked ;D
-
book marked also..
thats why we have to know php or java
the power of php..