Andreas01 - how to change banners per page?

aldus

As for a quick one: a typical job for "switch - case". e.g.

<?php
/**
*    @version     0.1.0
*    @date        2008-08-02
*    @package    WebsiteBaker - Code Examples
*
*/

    
switch (PAGE_TITLE) {
        case 
"Home"
            
$image_name "heaven.jpg"
            
$alt_str "this is the heaven";
            break;
            
        case 
"Photos":
            
$image_name "clouds.jpg";    
            
$alt_str "A rainy day in Georgia.";
            break;
            
        case 
"Math c1":
        case 
"Math c2":
        case 
"Math c3":
            
$image_name "math/fractals.jpg"
            
$alt_str "Math: fractals. A Reethmann/Loopfield area in details.";
            break;
            
        default:
            
$image_name "asterix.gif";
            
$alt_str "we don't need every time the magic-drink.";
    }
    
    
$img_html_str "img src=\"http://www.no_idea.biz/media/\"".$image_name."\" alt=\"".$alt_str."\" />\n";
?>

<!--
   some html in your template here
-->
<? echo $img_html; ?>


Regards
Aldus

pszilard

As a PHP dummy, using just code duplication, I got partway by using the following line:

<img id="frontphoto" src="<?php echo TEMPLATE_DIR?>/img/<?php echo PAGE_TITLE?>.jpg" width="760" height="175" alt="logo" />

where the original was before,

<img id="frontphoto" src="<?php echo TEMPLATE_DIR?>/img/front.jpg" width="760" height="175" alt="logo" />

Using PAGE_TITLE is a lot easier than PAGE_ID, however I need help on the syntax which should say
Pseudo code
IF PAGE_TITLE.jpg exist then PAGE_TITLE.jpg else default_banner.jpg


if you get the idea. How would then be coded in PHP?
Paul Szilard
WB user since Dec 2007:
[url="http://www.remektek.com.au/wb"]http://www.remektek.com.au/wb[/url]
[url="http://photos.remektek.com.au/"]http://photos.remektek.com.au/[/url] for my photo portfolio

Bramus

#2
You can do it by an if/else statement in the index.php of the template, for example.

<?php
if (PAGE_ID == 1){ ?>

<img src="http://www.bramus.nl/media/wereld-internet.png" alt="Hosting" />
<?php

if (
PAGE_ID == 2) { ?>

<img src="http://www.bramus.nl/media/image2.png" alt="Image2" />
<?php 
}
?>



If you use this you let PHP check what page id the page is they people are visiting, and then it takes the image correspondending to the page id.
BRAMUS Internet Services

pszilard

Hi, - I am using template: ANDREAS01

I would like to have different banners for each page. I thought if there was a way to define a default image (e.g banner.jpg) then if there existed a picture with the same name as the page, then it would be inserted, and if not found then it would default to the banner.jpg.

I.e. if the page was called HOME, then if HOME.jpg existed, then that would be used for the banner for the HOME page, but if there was no HOME.jpg, then it would use banner.jpg.

Second question is how to add the page title (h1 tagged) to appear on top of the banner?

Thanx in advance,
Paul Szilard
WB user since Dec 2007:
[url="http://www.remektek.com.au/wb"]http://www.remektek.com.au/wb[/url]
[url="http://photos.remektek.com.au/"]http://photos.remektek.com.au/[/url] for my photo portfolio