WebsiteBaker Community Forum

WebsiteBaker Support (2.8.x) => Droplets & Snippets => Topic started by: MicahK on March 01, 2008, 01:27:59 AM

Title: different banner on different pages
Post by: MicahK on March 01, 2008, 01:27:59 AM
How do I have a banner on say, Home, and a different banner on Contact Us?
Thanks,

Micah
Title: Re: different banner on different pages
Post by: BerndJM on March 01, 2008, 02:00:14 AM
Hi,

have look at the "Randomimage" Snipplet you can find at the addons page.
In addition you can should perform a search here in the forum for "random image" and you'll find some interesting stuff about it

Regards Bernd
Title: Re: different banner on different pages
Post by: MicahK on March 01, 2008, 02:29:41 AM
I thought about using the Random Image mod, but that will not work, as I need the banner to replace the main banner and not change, but only on certain pages.  I tried Sections, but could not get them to work... 
Title: Re: different banner on different pages
Post by: marathoner on March 01, 2008, 03:21:59 AM
I think it depends on your objective. Is it to have a random image or is the objective to use a given banner for certain pages (i.e. the contact us page would always use the contact us banner). If it's the later (which it sounds like) then you have several options:

1) Learn how to use sections
2) Create different templates that are exactly the same except for the banner and then use that template for the appropriate page
3) Use a little PHP in your template so that if page_id=1 then use banner1, and if page_id=2 then use a different banner.
Title: Re: different banner on different pages
Post by: MicahK on March 01, 2008, 03:45:21 AM
It is to have a given banner for a given page, you are correct.
I would prefer to use PHP, but I don't know it well enough.  Maybe I can find something I can use online.
The template idea would be a good bit more work, but I will try that.
Thanks!
Title: Re: different banner on different pages
Post by: marathoner on March 01, 2008, 03:54:26 AM
It's pretty easy, just include a bit of PHP in your template index.php where the banner is displayed and then call the appropriate banner based on the page_id. You can have as many different page/banner combinations as you want.

For example, I use this approach to include some java script on my pages...but only for those pages that use the JS. Here's my snippet (you'll need to modify to suit your needs by using an <IMG> tag):
Code: [Select]
<?php if (($page_id==27)||($page_id==29)||($page_id==34)||($page_id==37))
 {echo 
"<script type=\"text/javascript\" src=\"/js/general.js\"></script>\n";}?>


You would change this to basically something like "if page_id=X then use image Y otherwise use image Z"
Title: Re: different banner on different pages
Post by: MicahK on March 01, 2008, 05:57:33 AM
Pretty easy if you understand PHP...  :-D  Sadly, I am just starting.  I have just a little C# practice, and I think I know what I need, just cannot get it to work without errors.
I cannot get the if else to go... any suggestions, or should I take the question to a PHP forum?
Thanks!

Code: [Select]
<?php if (($page_id==4)||($page_id==7))
 {echo 
"<img=\"media/banner/testbanner.gif\" src=\"Banner\"></img>";} ......  ?>
Title: Re: different banner on different pages
Post by: BerndJM on March 01, 2008, 11:28:30 AM
Hi in your case it's an issue of "knowing how to code HTML".

Code: [Select]
<?php if (($page_id==4)||($page_id==7))
 {echo 
"<img src=\"media/banner/testbanner.gif\" alt=\"Banner\" />";}  ?>

Additional please have have a look on a html tutorial about the correct syntax for the img-tag

Regards Bernd

Title: Re: different banner on different pages
Post by: MicahK on March 01, 2008, 03:24:03 PM
Whoops!   :-o  I did not notice that.  However, it did not change anything. 
Thanks for noticing that.