on ech page a different image

crnogorac081

You can try this way :)) I use it to switch the picture or switch the css id :)))


<?php
if (PAGE_ID == 15) {
    echo 
WB_URL.'/multimedija/slike/15.jpg';
} elseif (
PAGE_ID == 16) {
    echo 
WB_URL.'/multimedija/slike/16.jpg';
} elseif (
PAGE_ID == 17) {
    echo 
WB_URL.'/multimedija/slike/17.jpg';
} else {
echo 
WB_URL.'/multimedija/slike/bijela.jpg';
}
?>



or


   <?php
    
if (PAGE_ID == 39) {
        echo 
" <div id='container1'> ";
    } elseif (
PAGE_ID == 17) {
        echo 
" <div id='container2'> ";
    } else {
    echo 
" <div id='container'> ";
    }
    
?>



cheersssss
Web developer

marathoner

A variation of Aldus's suggestion would be to have image name correspond to the page_id name. For example, if page_id=1 then display 1.jpg, if page_id=2 then display 2.jpg, etc. Much simpler script to do this.

aldus

Depence to the template you are working with / modifiy, you
will have to work with the $imagename; the 'switch' in the example only select a name ....  :-D

e.g.

<?php 

switch (PAGE_ID) {
    case 
12:
        
$my_imagename "sunset.jpg";
        break;
        
    case 
33:
    case 
34:
    case 
55:
        
$my_imagename "all_in_town.jpg";
        break;
    
    case 
123:
        
$my_imagename "photos_of_us.jpg";
        break;
        
    default:
        
$my_imagename "no_idea_about_photos.jpg";
        break;
}

$my_image_path WB_URL."/media/all_my_backgrounds/".$my_imagename;

echo 
"<img src='".$my_image_path."' alt='my image' />";

?>



so, if you've got somethink like

<img src="<?php echo TEMPLATE_DIR?>/img/zwshad.jpg" width="20" height="200" alt="" class="nopr"/>

inside your template you can modify it in diff. ways: this is one of them ...


<img src="<?php echo TEMPLATE_DIR?>/img/<?php echo $my_imagename?>" width="20" height="200" alt="" class="nopr"/>


If your images are inside the template-directory instead of the media-folder (in the example above) ...

Regards
Aldus

djdeeno

Oke its that al?
Only copy paste? I have try this but i don't see any image or hes trying to display one.

The name of the page is the same as titel of the page, example the welcome page has name welcome.php

Or is there a toher way?

Thanks again

aldus

Hm ... many way to do this.
You can use the buildin constant "PAGE_ID" to determinate
the page and select an image via a simple select inside you template-index.php...
e.g.

<?php 

switch (PAGE_ID) {
    case 
12:
        
$my_imagename "sunset.jpg";
        break;
        
    case 
33:
    case 
34:
    case 
55:
        
$my_imagename "all_in_town.jpg";
        break;
    
    case 
123:
        
$my_imagename "photos_of_us.jpg";
        break;
        
    default:
        
$my_imagename "no_idea_about_photos.jpg";
        break;
}

?>



Regards
Aldus

djdeeno

Hello, maybe is this item already exist but i can't find it anywhere.
There is 1 template and many pages, but is there a way to make on each pages a diferent

fotoimage, example, a webcam.php has a webcam picture on de banner, and so eacht pages

his own picture. I know how to edit the template. thats not the problem. Any idea?