different banner on different pages

MicahK

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

BerndJM

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

<?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

In theory, there is no difference between theory and practice. But, in practice, there is.

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!

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

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):
<?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"

MicahK

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!

marathoner

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.

MicahK

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... 

BerndJM

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
In theory, there is no difference between theory and practice. But, in practice, there is.

MicahK

How do I have a banner on say, Home, and a different banner on Contact Us?
Thanks,

Micah