WebsiteBaker Support (2.8.x) > Templates, Menus & Design

on ech page a different image

(1/2) > >>

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?

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.

--- Code: ---<?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;
}

?>

--- End code ---

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:
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.

--- Code: ---<?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=&#39;".$my_image_path."&#39; alt=&#39;my image&#39; />";

?>

--- End code ---

so, if you've got somethink like

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

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


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

--- End code ---

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

Regards
Aldus

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.

Navigation

[0] Message Index

[#] Next page

Go to full version