template or background switcher

mr-fan

hi,

<?php
$filename 
PAGE_TITLE;
$default 'basic.css'

if (file_exists($filename)) {
    
$file $filename;
} else {
    
$file $default;
}
?>

// CSS Ausgabe
<link href="<?php echo TEMPLATE_DIR?>/<?php echo $file?>.css" rel="stylesheet" type="text/css" media="screen" />


=> untested + could work with PAGE_ID, too

regards
martin

Ogierini

Should this really work, because it doesn't for me?

Is there any other script available, to change css per page?
Kind regards,Irene

Ogierini

Kind regards,Irene

Ogierini

Kind regards,Irene

aldus

Hello Irene

Sorry - no Dutch -

YOu will have to modify the url to the images - as i didn't knew where they are in my example.

So:

<?php
switch( 
PAGE_ID ) {
case 2:
case 22:
$image_name 'bgkoen.gif'// *!
break;

case 3:
$image_name "no_idea_about_the_name.gif"// *!
break;

default:
$image_name "not_found.gif";
}

$imgage_url WB_URL."/templates/a_bit_modern/Images/".$image_name// *!

?>

<style type="text/css">
#intro_right{
background: #179FB7 url(<?php echo image_url?>) no-repeat top left;
}
</style>



please take a (deeper) look for the lines marked with *!
Maybe this makes something clearer ;-)

Kind regards
Aldus

Ogierini

Thank you Aldus (Dutch?)
I put this code now in the head but it doesn't work yet.
Can your see why?


<?php
switch( 
PAGE_ID ) {
case 2:
case 22:
$image_name 'templates/a_bit_modern/Images/bgkoen.gif';
break;

default:
$image_name "not_found.gif";
}

$imgage_url WB_URL.MEDIA_DIRECTORY."/".$image_name// what/where ever ...

?>

<style type="text/css">
#intro_right{
background: #179FB7 url(<?php echo image_url?>) no-repeat top left;
}
</style>



And then, If I want to switch on page 3, how can I achieve that?

<?php
   switch( PAGE_ID ) {
      case 2:
      case 22:
         $image_name = 'templates/a_bit_modern/Images/bgkoen.gif';
         break;
Kind regards,Irene

aldus

Hello Irene

There are a couple of reasons that the code doesn't work at all, as
1) the style-tag attribute "type" has to be to set "text/css" **) and 2) the url
for the background-image has to point to a valid image[-format] (e.g. gif, jpg, png ...);
__not__ to a css-file at all:

<?php
    
if (( PAGE_ID == ) OR (PAGE_ID == 22)){
     
?>
<style type="text/css">
     #intro_right{
     background: #179FB7 url(<?php echo WB_URL.'styleskoen.jpg';?>) no-repeat;
     }
     </style><?php ?>
     
And 3) ist the image realy placed inside the WB-Root, instead of e.g. the media-folder?

Also, to avoid unreadable mess of "if - elseif - else OR - elseif AND - endif - but_no_if"-constructions
for future, if e.g. the site is growing - i would prefert a simple "switch" , e.g.

<?php
switch( 
PAGE_ID ) {
case 2:
case 22:
$image_name 'stylekoen.jpg';
break;

default:
$image_name "not_found.gif";
}

$imgage_url WB_URL.MEDIA_DIRECTORY."/".$image_name// what/where ever ...

?>

<style type="text/css">
#intro_right{
background: #179FB7 url(<?php echo image_url?>) no-repeat top left;
}
</style>



Kind regards
Aldus




**) You can leave the argument if you have specify in the head that you always use "text/css" e.g.

<meta http-equiv="Content-Style-Type" content="text/css">

Ogierini

hello guys,

I would like to have a different background on every page of a website.
I tried this code in the head but it doesn't work.
Has anyone a good suggestion?


<?php
    
if (( PAGE_ID == ) OR (PAGE_ID == 22)){
     
?>
<style type="styleskoen.css">
     #intro_right{
     background: #179FB7 url(<?php echo WB_URL.'styleskoen.css';?>) no-repeat;
     }
     </style><?php }

Thanks!
Kind regards,Irene