Advertisement:

Random Banner View

Aloittaja SeaChaser, toukokuu 31, 2011, 08:01:33 IP

« edellinen - seuraava »

SeaChaser

I have replaced the SMF logo with my own logo (banner sized picture). I would like to have multiple banners and have a random one be seen each time the user moves around or opens the forum. Can someone help me with this?

www.arimaboatownersgroup.com

TIA,

-SC

All Colours Sam

this is a very, very, very simple script for what you want:



$numbanners = 3; // number of banners to show
$random = rand(1,$numbanners);

$img = array();
$url = array();
$txt = array();

$img[1] = "banner1.gif";
$url[1] = "www.url.com";
$txt[1] = "text banner 1";

$img[2] = "banner2.gif";
$url[2] = "www.url2.com";
$txt[2] = "text banner 2";

$img[3] = "banner3.gif";
$url[3] = "www.url3.com";
$txt[3] = "text banner 3";

echo "<a href='$url[$random]' target='_blank'><img src='$img[$random]' alt='$txt[$random]' border='0'></a>";



you can put that on your index.template.php  and replace your logo with this:

echo "<a href='$url[$random]' target='_blank'><img src='$img[$random]' alt='$txt[$random]' border='0'></a>";

to show the random logo.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

SeaChaser

Thanks Miss All Sunday,

Is there a particular place in the index.template.php that I need to add your code?


Also, this line of code...

echo "<a href='$url[$random]' target='_blank'><img src='$img[$random]' alt='$txt[$random]' border='0'></a>";

is at the end of the code that I edit into the index.template.php code you told me to add.

I don't understand the comment "and replace your logo with this:"

Do I add that single line of code somewhere agan (it's already in the fist set of code that you noted)?

Thanks again. I can't wait to try it once you straighten me out.

All Colours Sam

Hi, yes, there are two part, this one:


$numbanners = 3; // number of banners to show
$random = rand(1,$numbanners);

$img = array();
$url = array();
$txt = array();

$img[1] = "banner1.gif";
$url[1] = "www.url.com";
$txt[1] = "text banner 1";

$img[2] = "banner2.gif";
$url[2] = "www.url2.com";
$txt[2] = "text banner 2";

$img[3] = "banner3.gif";
$url[3] = "www.url3.com";
$txt[3] = "text banner 3";



can be everywhere on your file as long as it don't break the php syntax.


this part:


echo "<a href='$url[$random]' target='_blank'><img src='$img[$random]' alt='$txt[$random]' border='0'></a>";




is the one that will replace your logo code,   attach your theme's  Index.template.php and we can tell you where to put this code.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

SeaChaser

I'm just getting back to trying this out. I'm a bit confused on editing in the logo code. I have attached my index.template.[php file which is just the default template for 1.14. I'm thinking that I need to replace line 197 with the logo code.

Thanks in advance.

-SeaChaser

All Colours Sam

Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

SeaChaser

Thanks but that's not working. The banners rotate thru the three banners I have but i lost the menu items and the ...


Show unread posts since last visit.
Show new replies to your posts.
There is one member awaiting approval.
Total time logged in: 16 days, 19 hours and 27 minutes.

the above items that are normally above the newsbar and next to my avatar.

Ricky.

Most probably you placed it somehwere which is not the right place for it.

Try to put it before theme_linktree() in index.template.php

Advertisement: