WebsiteBaker Logo
  • *
  • Templates
  • Help
  • Add-ons
  • Download
  • Home
*
Welcome, Guest. Please login or register.

Login with username, password and session length
 

News


WebsiteBaker 2.13.6 is now available!


Will it continue with WB? It goes on! | Geht es mit WB weiter? Es geht weiter!
https://forum.websitebaker.org/index.php/topic,32340.msg226702.html#msg226702


The forum email address board@websitebaker.org is working again
https://forum.websitebaker.org/index.php/topic,32358.0.html


R.I.P Dietmar (luisehahne) and thank you for all your valuable work for WB
https://forum.websitebaker.org/index.php/topic,32355.0.html


* Support WebsiteBaker

Your donations will help to:

  • Pay for our dedicated server
  • Pay for domain registration
  • and much more!

You can donate by clicking on the button below.

Donate with PayPal buttonSpenden mit dem PayPal-Button

  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • on ech page a different image
  • Print
Pages: [1]   Go Down

Author Topic: on ech page a different image  (Read 5122 times)

djdeeno

  • Guest
on ech page a different image
« on: February 23, 2009, 02:29:22 PM »
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?
Logged

aldus

  • Guest
Re: on ech page a different image
« Reply #1 on: February 23, 2009, 03:54:45 PM »
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: [Select]
<?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
Logged

djdeeno

  • Guest
Re: on ech page a different image
« Reply #2 on: February 23, 2009, 05:01:18 PM »
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
Logged

aldus

  • Guest
Re: on ech page a different image
« Reply #3 on: February 23, 2009, 05:46:47 PM »
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: [Select]
<?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; />";

?>


so, if you've got somethink like
Code: [Select]
<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 ...

Code: [Select]
<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
Logged

Offline marathoner

  • Posts: 495
Re: on ech page a different image
« Reply #4 on: February 24, 2009, 02:29:01 AM »
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.
Logged

Offline crnogorac081

  • Posts: 2161
  • Gender: Male
Re: on ech page a different image
« Reply #5 on: February 24, 2009, 09:40:58 AM »
You can try this way :)) I use it to switch the picture or switch the css id :)))

Code: [Select]
<?php
if (PAGE_ID == 15) {
    echo 
WB_URL.&#39;/multimedija/slike/15.jpg&#39;;
} elseif (PAGE_ID == 16) {
    echo 
WB_URL.&#39;/multimedija/slike/16.jpg&#39;;
} elseif (PAGE_ID == 17) {
    echo 
WB_URL.&#39;/multimedija/slike/17.jpg&#39;;
} else {
echo 
WB_URL.&#39;/multimedija/slike/bijela.jpg&#39;;
}
?>


or

Code: [Select]
   <?php
    
if (PAGE_ID == 39) {
        echo 
" <div id=&#39;container1&#39;> ";
    } elseif (
PAGE_ID == 17) {
        echo 
" <div id=&#39;container2&#39;> ";
    } else {
    echo 
" <div id=&#39;container&#39;> ";
    }
    
?>


cheersssss
Logged
Web developer

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • on ech page a different image
 

  • SMF 2.0.19 | SMF © 2017, Simple Machines
  • XHTML
  • RSS
  • WAP2