Welcome, Guest. Please login or register.
Did you miss your activation email?
May 23, 2012, 06:20:48 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155439 Posts in 21702 Topics by 7755 Members
Latest Member: Smacki
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Andreas01 - how to change banners per page?  (Read 1010 times)
pszilard

Offline Offline

Posts: 73


WWW
« on: August 02, 2008, 01:31:23 PM »

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,
Logged

Paul Szilard
WB user since Dec 2007:
http://www.remektek.com.au/wb
http://photos.remektek.com.au/ for my photo portfolio
Bramus
Forum Team
*****
Offline Offline

Posts: 601


WWW
« Reply #1 on: August 02, 2008, 02:09:43 PM »

You can do it by an if/else statement in the index.php of the template, for example.
Code:
<?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.
« Last Edit: August 02, 2008, 02:12:19 PM by Bramus » Logged

BRAMUS Internet Services
pszilard

Offline Offline

Posts: 73


WWW
« Reply #2 on: August 02, 2008, 02:27:01 PM »

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

Code:
<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,

Code:
<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
Code:
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?
Logged

Paul Szilard
WB user since Dec 2007:
http://www.remektek.com.au/wb
http://photos.remektek.com.au/ for my photo portfolio
aldus

Offline Offline

Posts: 1238


« Reply #3 on: August 02, 2008, 02:52:22 PM »

As for a quick one: a typical job for "switch - case". e.g.
Code:
<?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
Logged
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!