Dynamically changing image using only one CSS file - Joomla! Forum - community, help and support


hello,

i want change image in template depending on button click.
i know can done using variable id-attribute of
combined using different background image in css file.
for example
in de php file, have:
...
in css file have serveral backgrounds defined different images.

what still didn't figure out how set $nbr value depending on button clicked.
can point me php script can this?

thanks
last edited cocoony on wed nov 01, 2006 11:25 pm, edited 1 time in total.

firstly if wanting different header images per category / section sure there add on module in extensions directory this

for own template based solution, depend on "buttons" refer to.

if buttons adding link url to, can e.g. add own value in url

e.g. if link

mysite/index.php

you add ?bg=1

mysite/index.php?bg=1

then reference e.g.

code: select all

$nbr = $_get['bg'];


to make safer code, can ensure values intend passed:

this tests submitted url against allowed array of values ( numbers 1 10 ). if value bg passed in url number between 1 , 10 used create css class e.g. background2 otherwise defaul class assigned

code: select all

<?php
$bgsuffix = $_get['bg'];
$allowed = range(1,10);
if ( in_array($bgsuffix, $allowed) ) {
$bgclass = "background$bgsuffix";
}
else {
$bgclass = "backgrounddefault";
}
?>


this can output e.g.

code: select all

<div id='<?php echo $bgclass; ?>'>


if "buttons" joomla menu items, not have same ability add own custom value , may more difficult pick out unique value passed in url although can done.





Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support