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.


  • Home
  • Help
  • Search
  • Login
  • Register

  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Andreas01 - how to change banners per page?
  • Print
Pages: [1]   Go Down

Author Topic: Andreas01 - how to change banners per page?  (Read 4791 times)

Offline pszilard

  • Posts: 75
  • Gender: Male
    • RemekTek
Andreas01 - how to change banners per page?
« on: August 02, 2008, 02: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

Offline Bramus

  • Posts: 608
  • Gender: Male
    • BRAMUS Internet Services
Re: Andreas01 - how to change banners per page?
« Reply #1 on: August 02, 2008, 03:09:43 PM »
You can do it by an if/else statement in the index.php of the template, for example.
Code: [Select]
<?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, 03:12:19 PM by Bramus »
Logged
BRAMUS Internet Services

Offline pszilard

  • Posts: 75
  • Gender: Male
    • RemekTek
Re: Andreas01 - how to change banners per page?
« Reply #2 on: August 02, 2008, 03:27:01 PM »
As a PHP dummy, using just code duplication, I got partway by using the following line:

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

  • Guest
Re: Andreas01 - how to change banners per page?
« Reply #3 on: August 02, 2008, 03:52:22 PM »
As for a quick one: a typical job for "switch - case". e.g.
Code: [Select]
<?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&#39;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

  • Print
Pages: [1]   Go Up
  • WebsiteBaker Community Forum »
  • WebsiteBaker Support (2.8.x) »
  • Templates, Menus & Design »
  • Andreas01 - how to change banners per page?
 

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