WebsiteBaker Support (2.8.x) > Droplets & Snippets

different banner on different pages

<< < (2/2)

marathoner:
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: ---<?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";}?>

--- End code ---

You would change this to basically something like "if page_id=X then use image Y otherwise use image Z"

MicahK:
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: ---<?php if (($page_id==4)||($page_id==7))
 {echo "<img=\"media/banner/testbanner.gif\" src=\"Banner\"></img>";} ......  ?>
--- End code ---

BerndJM:
Hi in your case it's an issue of "knowing how to code HTML".


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

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

Regards Bernd

MicahK:
Whoops!   :-o  I did not notice that.  However, it did not change anything. 
Thanks for noticing that.

Navigation

[0] Message Index

[*] Previous page

Go to full version