TinyPortal

Development => Block Codes => Topic started by: ash on October 10, 2007, 07:23:29 PM

Title: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: ash on October 10, 2007, 07:23:29 PM
This may not be new to some of you, but it’s me trying to give back to this community who has given me so much.

These codes allow you to have a rotating banner on the very top of your forum.  So, each time an action is performed on the forum, the banner will change to one you have predefined.  This works good if you remove the default theme banner first, or just replace it with a blank picture so you don’t have two banners going at the same time ^^

You can see how it looks on my forum here:  http://thegamedomain.org/tgdmain    NO PW needed :)

First thing is to create your banners.  Make sure that all the banners are the same width and height so that the transition doesn’t look goofy.  If you have a black or white background on your forum, just use those colors to fill in the extra space if you banners are not the same size.

For my banners, I have created four at 1050 x 158, all with black backgrounds to match my forum.

Now to make it all happen ;)

First you need a webpage with the rotating image code in a Div layer that eliminates the spaces at the top and left of the page (Set left and top to 0px).  Lucky for you, I have attached that page for you.  All you need to do is edit it to have the image URL’s match your own and change the background of the page to whatever matches your forum. (I’ve also attached the rotate script without the webpage.)

Simply open the webpage up, view the code and change the URL’s and background color.  Then save it.  If you don’t rename it, you don’t have to change the name of the page in the IFrame code below.

Ok, next step.
   
1.   Go to your admin panel in your forum and choose “Current Theme”
2.   Search for </head>
3.   Right above </head> add the code in the attached file called “Preload”.  This is; you guessed it, a code that will preload all your images so that the load time on your forum isn’t much affected.  Make sure that you change the image URL’s to where your banners are actually stored and call the images something different.
4.   After </head> paste the IFrame code (Below).  Make sure if you renamed the webpage I attached here to also change the name in the IFrame code.
5.   Hit save.  (oh yea, make sure you upload the webpage to your server somewhere and fix the URL in the IFrame to match ^^ )


That’s it.  You should now have a rotating banner at the very top of your forum.


I believe I’ve covered all the steps here.  I pretty much suck at writing things up for other people to understand, so if I missed something, feel free to slap me around in your reply and I will correct.

Hope this works out for you and you get some use out of it.
Works in Firefox but make sure to put the center tags around your IFrame <center>Iframe</center>


IFRAME CODE (Modify as needed):
<iframe name="I1" id="I1" src="http://thegamedomain.org/banners/test.htm" marginwidth="1050" marginheight="158" scrolling="no" border="0" frameborder="0" style="width: 1052px; left: 0px; right: 0px" height="158">Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>



Take Care,
Ash
www.thegamedomain.com
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: Reality12 on November 11, 2007, 04:14:37 AM
sounds exactly like something i want on my forum, but i've got an error when i try to implement it.

The file you tried to save generated the following error:
Parse error: syntax error, unexpected '>' in index.template.php on line 252


i've also uploaded the 'test' page into my forum root directory and changed the names accordingly.

here's what the code i've pasted looks like:

<SCRIPT language="JavaScript">
<!--
if (document.images)
{
  adBanner1= new Image(856,179);
  adBanner1.src="MY IMAGE URL";


  adBanner2= new Image(856,179);
  adBanner2.src="MY IMAGE URL";

}
//-->
</SCRIPT>
<script language="JavaScript">
<!-- Begin
rnd.today=new Date();
rnd.seed=rnd.today.getTime();
function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};
function rand(number) {
   var result = Math.ceil(rnd()*number);
   if (!result)result++;
        return result
};
var ad_cnt1 = 4;
var ad1 = rand(ad_cnt1);
var link1;
var adBanner1;
var width1
var height1
if (ad1==1) {
adBanner1="MY IMAGE URL";
width1="856";
height1="179";
alt1="MY WEBSITE NAME";
}
if (ad1==2) {
adBanner1="MY IMAGE URL";
width1="856";
height1="179";
alt1="MY WEBSITE NAME";
}
document.write('<center><a href="' + link1 + '" target="_top">');
document.write('<img src="' + adBanner1 + '" width=' + width1 + ' height=' + height1 + ' border=0 alt="' + alt1 + '"></a>');
document.write('</center>');
// End -->
</SCRIPT>
</head>


what have i done wrong?
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: Reality12 on November 11, 2007, 04:19:03 AM
here's what the 'test' page has:



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled 1</title>
</head>

<body style="background-color: #000000">


<div style="position: absolute; width: 1050px; height: 158px; z-index: 1; left: -1px; top: -1px" id="layer1">
<table style="width: 100%">
<tr>
<td>
<script language="JavaScript">
<!-- Begin
rnd.today=new Date();
rnd.seed=rnd.today.getTime();

function rnd() {
        rnd.seed = (rnd.seed*9301+49297) % 233280;
        return rnd.seed/(233280.0);
};

function rand(number) {
var result = Math.ceil(rnd()*number);
if (!result)result++;
        return result
};
var ad_cnt1 = 4;
var ad1 = rand(ad_cnt1);
var link1;
var adBanner1;
var width1
var height1
if (ad1==1) {
adBanner1="MY IMAGE URL";
width1="856";
height1="179";
alt1="MY WEBSITE NAME";
}
if (ad1==2) {
adBanner1="MY IMAGE URL";
width1="856";
height1="179";
alt1="MY WEBSITE NAME";
}
document.write('<center><a href="' + link1 + '" target="_top">');
document.write('<img src="' + adBanner1 + '" width=' + width1 + ' height=' + height1 + ' border=0 alt="' + alt1 + '"></a>');
document.write('</center>');
// End -->
</SCRIPT>
&nbsp;</td>
</tr>
</table>
</div>


</body>

</html>
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: Reality12 on November 15, 2007, 11:14:33 PM
can anyone help with this?
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: IchBin on November 15, 2007, 11:18:07 PM
Did you follow the instructions above? Put it in your template file like suggested with the iframe code? Sounds like you're not doing it that way.
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: b33znutz on June 05, 2008, 02:17:20 PM
this is what ive been lookin for! gonna try this! even though its like a year later, i will post my findings. thanks ash!
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: b33znutz on June 05, 2008, 08:26:39 PM
i got the same prob. parse error.. and mine ended up more or less like ~Alex's did.... and zero support. wish i knew code. the author hasnt been around since oct of last year.. redicluous. im frustrated if u cant tell.......grrrrrrrrrrrrrrrrrrrrr
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: JPDeni on June 05, 2008, 11:10:59 PM
What code did you use? Exactly? Please post it, using [ code ] tags. What kind of block did you put it in?
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: nstutsman on June 05, 2008, 11:39:59 PM
I use a php script to rotate banners.  No issues, just put the php in a folder with all the banners you want to rotate.  Just point the image location to the file, i.e. on my site http://geeksbling.com, the banner is pointed to http://geeksbling.com/squad/headerbgs/index.php.  I have about 17 banners in there, it randomly rotates among all of them.  I even have additional folders in there, for different events (xmas, etc.)  Just dump all the normal banners into a temp dump, and move the seasonal ones into the main folder.

This isn't my script, so I won't take credit.  But it works for an idiot like me, so it's gotta work for you :)
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: ash on June 10, 2008, 05:46:32 PM
Sorry for the absence.  Thanks b33znutz for letting me know I needed to come back here to reply.

Seems I made a typo in the above instructions where I stated to paste the IFRAME code inside the head instead of right after the head (D’oH!). 
I have corrected the above instructions.

Keep in mind; you don't paste the code from the .htm file in the index template, just the IFRAME code and the preload code, if you want to. (IMO its not really needed)

To simplify things, create a folder on you host called banners or whatever; put all your images and the test.htm file in there (This is what I’ve done).
Then just paste in the IFRAME code immediately AFTER </head>.

1. So, :find:  </head>

2. Paste after: </head>

<iframe name="I1" id="I1" src="http://thegamedomain.org/banners/test.htm" marginwidth="1050" marginheight="158" scrolling="no" border="0" frameborder="0" style="width: 1052px; left: 0px; right: 0px" height="158">Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>



This is where I pasted mine.   (After </head> and before <body>)  Your banners will then be at the tippy-top of your forum  ;D

</head>
<iframe name="I1" id="I1" src="http://thegamedomain.org/banners/test.htm" marginwidth="1050" marginheight="158" scrolling="no" border="0" frameborder="0" style="width: 1052px; left: 0px; right: 0px" height="158">Your browser does not support inline frames or is currently configured not to display inline frames.
</iframe>
<body>



I’m using the code in my forum again, so you can see it and copy the source code if needed.  I’ll remove it here after the week is over.
Thegamedomain.org â€" select the Community Forum link, not the WoWarcraft link  ;D


Sorry for any inconveniences.
<3 Ash
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: b33znutz on June 11, 2008, 01:50:55 AM
Quote from: ash on June 10, 2008, 05:46:32 PM
Sorry for the absence.  Thanks b33znutz for letting me know I needed to come back here to reply.

no prob dude. sorry if i sounded rude, just frustrated with this one, and other things having to do with my SMF/TP modding... gonna try again.. will let you know! thanks!

Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: ash on June 11, 2008, 08:33:04 PM
Its all good.

<3
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: Reality12 on June 13, 2008, 02:39:25 AM
Quote from: nstutsman on June 05, 2008, 11:39:59 PM
I use a php script to rotate banners.  No issues, just put the php in a folder with all the banners you want to rotate.  Just point the image location to the file, i.e. on my site http://geeksbling.com, the banner is pointed to http://geeksbling.com/squad/headerbgs/index.php.  I have about 17 banners in there, it randomly rotates among all of them.  I even have additional folders in there, for different events (xmas, etc.)  Just dump all the normal banners into a temp dump, and move the seasonal ones into the main folder.

This isn't my script, so I won't take credit.  But it works for an idiot like me, so it's gotta work for you :)

i like the script. is it possible to code the script to open images in a new page once clicked?
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: Reality12 on June 13, 2008, 02:54:34 AM
guess i should say i'm currently looking for help with a block that features random images, but will open up a new page if that image is clicked...
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: JPDeni on June 13, 2008, 03:04:19 AM
Try http://www.tinyportal.net/index.php?topic=24242.msg195425#msg195425
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: Reality12 on June 13, 2008, 07:12:02 AM
i like you. :)

see link you provided for the rest of this post.
Title: Re: Rotating Banners for your TP forum! (Works for FF and IE)
Post by: ash on August 21, 2008, 12:00:21 AM
the code to open something in a new window when selected is:
<p><a target="_blank" href="http://thegamedomain.org/tgdmain/"><img border="0" src="your_picture.jpg" width="233" height="157"></a></p>

Specifically:  target="_blank" added to the URL.

but they have a random picture mod here in Snippits.  Shows a random image from some image folder.  When you cvlick it, the picture opens the picture in a new window.

O0