Simple Machines Community Forum

Customizing SMF => Modifications and Packages => Mod Requests => Aiheen aloitti: SeaChaser - toukokuu 31, 2011, 08:01:33 IP

Otsikko: Random Banner View
Kirjoitti: SeaChaser - toukokuu 31, 2011, 08:01:33 IP
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
Otsikko: Re: Random Banner View
Kirjoitti: All Colours Sam - toukokuu 31, 2011, 08:09:11 IP
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.
Otsikko: Re: Random Banner View
Kirjoitti: SeaChaser - kesäkuu 03, 2011, 01:50:39 AP
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.
Otsikko: Re: Random Banner View
Kirjoitti: All Colours Sam - kesäkuu 05, 2011, 05:20:35 IP
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.
Otsikko: Re: Random Banner View
Kirjoitti: SeaChaser - syyskuu 02, 2011, 12:30:21 AP
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
Otsikko: Re: Random Banner View
Kirjoitti: All Colours Sam - syyskuu 02, 2011, 09:41:26 AP
try this one
Otsikko: Re: Random Banner View
Kirjoitti: SeaChaser - syyskuu 03, 2011, 02:36:25 AP
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.
Otsikko: Re: Random Banner View
Kirjoitti: Ricky. - syyskuu 03, 2011, 11:01:42 AP
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