Elxis CMS Forum
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Which version to download?: Elxis 4.0 and Elxis 2009.3 comparison
 
Pages: [1]
  Print  
Author Topic: changing bg image in div every time you call different menu link  (Read 3692 times)
babis1
Hero Member
*****
Offline Offline

Posts: 1496



WWW
« on: October 06, 2010, 09: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)................................. Huh thanks !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Logged

datahell
Elxis Team
Hero Member
*****
Offline Offline

Posts: 7587



WWW
« Reply #1 on: October 06, 2010, 17: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.
« Last Edit: October 06, 2010, 17:36:59 by datahell » Logged

babis1
Hero Member
*****
Offline Offline

Posts: 1496



WWW
« Reply #2 on: October 06, 2010, 17: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> ?
Logged

webgift
Elxis Team
Hero Member
*****
Offline Offline

Posts: 3240



WWW
« Reply #3 on: October 06, 2010, 17:41:43 »

Just before the <div class="header<?php echo $sfx; ?>">  Wink
Logged

babis1
Hero Member
*****
Offline Offline

Posts: 1496



WWW
« Reply #4 on: October 06, 2010, 17:42:22 »

ok thanks a lot i go to try it  Grin Grin Grin
--------after----------------------------
ok it works fine !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! i need it only for 5 items, because there i cant have module position
« Last Edit: October 06, 2010, 17:52:11 by babis1 » Logged

babis1
Hero Member
*****
Offline Offline

Posts: 1496



WWW
« Reply #5 on: October 20, 2010, 09:40:54 »

ok another one if i want to use the same img in more than one items pe case 2,29,30.....
Logged

webgift
Elxis Team
Hero Member
*****
Offline Offline

Posts: 3240



WWW
« Reply #6 on: October 20, 2010, 10: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;  }
« Last Edit: October 20, 2010, 10:51:49 by WebGift » Logged

Amigamerlin
Full Member
***
Offline Offline

Posts: 233



« Reply #7 on: October 20, 2010, 11: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
Logged
ArXoS
Hero Member
*****
Offline Offline

Posts: 758



WWW
« Reply #8 on: November 04, 2010, 00:01:45 »

 Shocked Shocked Shocked bookmarked  Grin
Logged

ahmet
Sr. Member
****
Offline Offline

Posts: 253


360 HDR Virtual Tours | Windsurfing Sailing


WWW
« Reply #9 on: January 05, 2012, 20:05:46 »

book marked also..
thats why we have to know php or java
the power of php..
Logged

Pages: [1]
  Print  
 
Jump to: