php forum
php mysql forum
php mysql smarty
 
Page 1 of 2 1 2 >
Topic Options
#281010 - 10/21/04 03:52 AM Finished-[All] Multiple Random Banners v1.1 (No Duplicates) *updated*
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Mod Name / Version: Multiple Random Banners v1.1 (No Duplicates) <br /> <br />Description: This updated script will allow you to display multiple random images or banners on your site without ever showing duplicates, and it is also more user friendly now. <br /> <br />It is tailored to be used for UBBThreads via the generic or forum headers, although it can easily be used on any PHP page as well. (it looks like footer includes need to be added to the send_footer() function in ubbt.inc.php instead, or else it won't work - not sure why that is). <br /> <br />Instructions <br />============ <br /> <br />1) Download and save the script (banners.inc.php) to your UBBThreads includes folder. <br /> <br />2) Then configure the script by filling in the HTML for each banner listed. If you ever want to change/delete banners in the future you can easily edit the HTML code here. <br /> <br />3) Configure how many banners you wish to display on the page (0 to 12) from the entire pool of available ones. <br /> <br />4) Then simply include this code in your header/footer... <br />Adjust the path as necessary if you are using it on a non-threads page. <br /> <br /><? include "$thispath/includes/banners.inc.php"; ?> <br /> <br /> <br />DEMO - <br />http://www.mameworld.info/ubbthreads/demo.php <br /> <br /> <br />Working Under: UBB.Threads 6.0-6.5 <br /> <br />Mod Status: Finished <br /> <br />Any pre-requisites: <br /> <br />Author(s): Twisty <br /> <br />Date: 10/21/04 <br /> <br />Credits: <br /> <br />Files Altered: <br /> <br />New Files: <br /> <br />Database Altered: <br /> <br />Info/Instructions: (see attachment) <br /> <br />Disclaimer: Please backup every file that you intend to modify. <br />If the modification modifies the database, it's a good idea to backup your database before doing so. <br /> <br />Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop.If you need official support, you'll need to restore unmodified files.


Attachments
121715-banners.inc.zip (42 downloads)


Top
#281011 - 10/24/04 08:11 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
If I were to put this part <br />
Code:
<br />// This section can be called via an include if you wish <br /><br />$image_html = array();<br /><br />// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ")<br />// You can also add individual ALT and TITLE tags if you wish<br /><br />$image_html[0] = "&lt;a href=\"http://www.example1.com\"&gt;&lt;img src=\"images/1.gif\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[1] = "&lt;a href=\"http://www.example2.com\"&gt;&lt;img src=\"images/2.jpg\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[2] = "&lt;a href=\"http://www.example3.com\"&gt;&lt;img src=\"images/3.png\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[3] = "&lt;a href=\"http://www.example4.com\"&gt;&lt;img src=\"images/4.gif\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[4] = "&lt;a href=\"http://www.example5.com\"&gt;&lt;img src=\"images/5.jpg\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[5] = "&lt;a href=\"http://www.example6.com\"&gt;&lt;img src=\"images/6.png\" border=\"0\"&gt;&lt;/a&gt;";<br /><br />// Configure the number of unique images or banners to be displayed on the page<br />// It can be any number from 0-6 in the example given<br /><br />$number_of_images = 3; // &lt;-- Configure<br /><br />$random = array_rand($image_html, $number_of_images);<br />?&gt; <br />
<br />into a file named banner.inc.php <br /><br />where would I put the following line of code?Or am I going about this wrong?<br />require ("includes/banner.inc.php");<br /><br /><br />This I have placed in my Generic Header
Code:
 &lt;center&gt;<br /><br />&lt;?php echo $image_html[$random[0]]; ?&gt;<br />&lt;?php echo $image_html[$random[1]]; ?&gt;<br />&lt;?php echo $image_html[$random[2]]; ?&gt;<br />&lt;?php echo $image_html[$random[3]]; ?&gt;<br />&lt;?php echo $image_html[$random[4]]; ?&gt;<br />&lt;?php echo $image_html[$random[5]]; ?&gt;<br />&lt;/center&gt; 
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281012 - 10/25/04 06:14 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
You could place it in several locations. <br /> <br />1) In the actual ubbt_header.tmpl file right after this... <br /> <br /><? //UBBTREMARK <br /> <br />2) Paste the code somewhere in ubbt.inc.php <br /> <br />3) Save it as an include like you mentioned, and then paste this into ubbt.inc.php... <br /> <br />include ("$thispath/includes/banner.inc.php"); <br /> <br />...right underneath the others listed... <br /> <br /> include("$configdir/config.inc.php"); <br /> include("$thispath/mysql.inc.php"); <br /> include("$thispath/theme.inc.php"); <br /> <br />I would personally use the 3rd method just to keep everything orderly, and allow easier editing of the html code. <br /> <br /><img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" />
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281013 - 10/25/04 06:19 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
do you mean these?<br /><br />require_once("$configdir/config.inc.php");<br />require_once("$thispath/mysql.inc.php");<br />require_once("$thispath/includes/theme.inc.php");<br />require_once("$thispath/includes/configpal.inc.php");
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281014 - 10/25/04 06:36 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Yes, I'm using 6.3 which is a li'l different. Although still use the same line I mentioned though. <br /> <br />I recommend using include() over require_once() since it is a non-critical file. <br /> <br />The former will merely give a warning upon failure while the latter will give a fatal error, which would be more understandable for the other listed includes.
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281015 - 10/25/04 06:39 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
// This section can be called via an include if you wish $image_html = array(); // Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ") // You can also add individual ALT and TITLE tags if you wish $image_html[0] = ""; $image_html[1] = ""; $image_html[2] = ""; $image_html[3] = ""; $image_html[4] = ""; $image_html[5] = ""; // Configure the number of unique images or banners to be displayed on the page // It can be any number from 0-6 in the example given $number_of_images = 6; // <-- Configure $random = array_rand($image_html, $number_of_images); ?><br />Warning: Cannot modify header information - headers already sent by (output started at /usr/www/efs/ubbthreads/includes/banner.inc.php:10) in /usr/www/efs/ubbthreads/ubbt.inc.php on line 328<br /><br />What did I do wrong here? That is showing where I would like my banners? I placed the code in my header insert
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281016 - 10/25/04 07:04 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Ok I think this can be fixed using output buffering. Try adding this to your banner include... <br /> <br />At the begining of the code put this line: <br /> <br />//begin buffering <br />ob_start(); <br /> <br /> <br />and at the end of the code put this line: <br /> <br /> <br />//end buffering <br />ob_end_flush(); <br /> <br /> <br />Lemme know how it works.
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281017 - 10/25/04 07:07 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
well one thing I forgot was this at the top of my banner.inc.php <br /><?php <br />It must be pretty important <img src="http://www.ubbdev.com/forum/images/graemlins/jester.gif" alt="" /> <br /> <br /> <br /> <br /> <br />so now I am getting just this <br /> <br />Warning: Cannot modify header information - headers already sent by (output started at /usr/www/efs/ubbthreads/includes/banner.inc.php:24) in /usr/www/efs/ubbthreads/ubbt.inc.php on line 328 <br /> <br />I will try the the buffering now- <br />*edit-still getting that last error even after inserting the buffer code*


Edited by ChAoS (10/25/04 07:13 PM)
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281018 - 10/25/04 07:23 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Ugh, if using an include like that, I know there's a way to do it with buffering but I'd have to play around with it a bit and test some things. <br /> <br />For now just include all the code in the header template and it should work a-ok. <br /> <br />EDIT: See my post below for an example
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281019 - 10/25/04 07:35 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Something else to try if going the include route... <br /> <br />Do the same thing I mentioned above with the output buffering but add those beginning and ending lines to ubbt.inc.php instead of the banner include. That *might* work.
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281020 - 10/25/04 07:56 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Here's a follow-up to what you'll need to do if including everything in the header template (a little extra code req'd)...<br /><br />Example (displaying 3 images from a pool of 3 possible):<br /><br /><? //UBBTREMARK<br /><br />$image_html = array();<br /><br />// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ")<br />// You can also add individual ALT and TITLE tags if you wish<br /><br />$image_html[0] = "<a href=\"http://www.example1.com\"><img src=\"images/1.gif\" border=\"0\"></a>";<br />$image_html[1] = "<a href=\"http://www.example2.com\"><img src=\"images/2.jpg\" border=\"0\"></a>";<br />$image_html[2] = "<a href=\"http://www.example3.com\"><img src=\"images/3.png\" border=\"0\"></a>";<br /><br />// Configure the number of unique images or banners to be displayed on the page<br />// It can be any number from 0-6 in the example given<br /><br />$number_of_images = 3; // <-- Configure<br /><br />$random = array_rand($image_html, $number_of_images);<br /><br />[:"red"]$image1 = $image_html[$random[0]];<br />$image2 = $image_html[$random[1]];<br />$image3 = $image_html[$random[2]];[/] <br /><br /><br />echo <<<UBBTPRINT<br /><!-- START OF header.tmpl TEMPLATE --><br /><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br /><html dir="{$ubbt_lang['READ_DIRECTION']}"><br /><head><br />$headerinsert<br />$refresh<br /><meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" /><br /><link rel="stylesheet" href="$stylesheet" type="text/css" /><br /><link rel="shortcut icon" href="{$config['images']}/loonyicon.ico" /><br />$javascript<br /><title>{$config['title']}: $inputTitle</title><br /></head><br /><body><br />[:"red"]<center><br />$image1<br />$image2<br />$image3<br /></center> [/] <br /><!-- END OF header.tmpl TEMPLATE --><br />UBBTPRINT<br />/* UBBTREMARK */ ?><br /><br /><br />Now notice the parts in red. <br /><br />The first red section is *new code* you'll need, which converts the randomized array into single variables. It's pretty straight-forward.<br /><br />The second red section is what will actually display the images now with the variables we just created above.<br /><br />I think it's pretty easy to understand eh? That will now absolutely make everything work using this method!
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281021 - 10/25/04 08:07 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
ok I placed it in the ubbt_header.tmpl and it displays the images but does not do it randomly<br /><br />If I assign this value<br />$number_of_images = 3; // <-- Configure<br />I get the same three images upon refreshing (the first three on the list I believe)<br /><br />If I assign a value of<br />$number_of_images = 1; // <-- Configure <br />then nothing displays<br /><br /><br />Here is my ubbt_header.tmpl<br />
Code:
 &lt;!-- &lt;? //UBBTREMARK --&gt;<br />// File Version 6.5<br />[:"green"]<br />$image_html = array();<br /><br />// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ")<br />// You can also add individual ALT and TITLE tags if you wish<br /><br />$image_html[0] = "&lt;a href=\"http://www.bajema.com\"&gt;&lt;img src=\"/ubbthreads/images/banners/bajbnr.jpg\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[1] = "&lt;a href=\"http://melancholic.net\"&gt;&lt;img src=\"/ubbthreads/images/banners/melancholicban.jpg\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[2] = "&lt;a href=\"http://www.decayingmadness.com\"&gt;&lt;img src=\"/ubbthreads/images/banners/decayingmadness.gif\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[3] = "&lt;a href=\"http://www.vixenshop.com\"&gt;&lt;img src=\"/ubbthreads/images/banners/vixshop.gif\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[4] = "&lt;a href=\"http://www.giger.com/mainflash.htm\"&gt;&lt;img src=\"/ubbthreads/images/banners/giger.jpg\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[5] = "&lt;a href=\"http://www.pitchfork.de/page_en.php?\"&gt;&lt;img src=\"/ubbthreads/images/banners/projectpitchfork.jpg\" border=\"0\"&gt;&lt;/a&gt;";<br />$image_html[6] = "&lt;a href=\"http://emeraldforestseattle.com\"&gt;&lt;img src=\"/ubbthreads/images/happyhalloween.gif\" border=\"0\"&gt;&lt;/a&gt;";<br /><br />// Configure the number of unique images or banners to be displayed on the page<br />// It can be any number from 0-6 in the example given<br /><br />$number_of_images = 1; // &lt;-- Configure<br /><br />$random = array_rand($image_html, $number_of_images);<br /><br />[/]<br />&lt;!-- echo &lt;&lt;&lt;UBBTPRINT --&gt;<br />&lt;!-- START OF header.tmpl TEMPLATE --&gt;<br />&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;<br />&lt;html dir="{$ubbt_lang['READ_DIRECTION']}"&gt;<br />&lt;head&gt;<br />$headerinsert<br />$refresh<br />&lt;meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" /&gt;<br />&lt;link rel="stylesheet" href="$stylesheet" type="text/css" /&gt;<br />&lt;link rel="shortcut icon" href="{$config['images']}/favicon.ico" /&gt;<br />$javascript<br />&lt;title&gt;{$config['title']}: $inputTitle&lt;/title&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;!-- END OF header.tmpl TEMPLATE --&gt;<br />&lt;!-- UBBTPRINT --&gt;<br />&lt;!-- /* UBBTREMARK */ ?&gt; --&gt;<br /> 
<br /><br /><br />And here is my generic header
Code:
 &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;<br /><br />&lt;title&gt;Emerald Forest Seattle &lt;/title&gt;<br /><br /><br /><br />&lt;body bgcolor="#7b9b74"&gt;<br /><br /><br />&lt;center&gt;&lt;p&gt;<br />&lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt;&lt;tr&gt;<br />&lt;td width="80%" align="center" valign="middle"&gt;<br />&lt;img src="/efsbanner.gif"&gt;<br /><br /><br />&lt;br&gt;<br />&lt;br&gt;<br />&lt;/td&gt;<br />&lt;/tr&gt;<br />&lt;/table&gt;<br /><br />&lt;table border="0" cellspacing="1" cellpadding="2" width="95%"bgcolor="#000000"&gt;&lt;tr bgcolor="#7C8F79"&gt;&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt;<br /><br />&lt;b&gt;&lt;a href="/faq.html" target="_new"&gt;Rules&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;<br /><br />&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="http://efs.stats.nuclearfallout.net"target="_new"&gt;Statistics&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;<br /><br />&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="http://216.254.1.196/~chaos/live1.6.html" target="_new"&gt;LiveStatus&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;<br /><br />&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="/efclan/staff.html" target="_new"&gt;Staff&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;<br /><br />&lt;td align="center" width="20%" background="http://emeraldforestseattle.nuclearfallout.net/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="/Links.html" target="_new"&gt;Links&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;<br />&lt;/table&gt;<br /><br />&lt;br /&gt;<br /><br />&lt;!--THIS PART GOES INTO THE GENERIC HEADER--&gt;&lt;div align="center"&gt;&lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt;&lt;tr&gt;&lt;td align="center" valign="top"&gt;<br /><br /><br />        &lt;table border="0" cellspacing="1" cellpadding="2" width="95%" bgcolor="#000000"&gt;<br />          &lt;tr&gt;<br />          &lt;td width="20%" class="welcome"&gt;<br />            &lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt;<br />            &lt;input type="hidden" name="cmd" value="_xclick"&gt;<br />            &lt;input type="hidden" name="business" value="chaos@emeraldforestseattle.com"&gt;<br />            &lt;input type="image" src="http://emeraldforestseattle.nuclearfallout.net/ubbthreads/images/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"&gt;<br />            &lt;/form&gt;<br />            &lt;b&gt;Send Money!&lt;/b&gt;<br />          &lt;/td&gt;<br /><br />	  &lt;td width="60%" td bgcolor="#92A88E"&gt;<br />&lt;br&gt;&lt;/ br&gt;<br />&lt;center&gt;Welcome To The Forest&lt;/center&gt;<br />&lt;center&gt;<br />[:"green"]<br />&lt;/center&gt;&lt;center&gt;<br />&lt;?php echo $image_html[$random[0]]; ?&gt;<br />&lt;?php echo $image_html[$random[1]]; ?&gt;<br />&lt;?php echo $image_html[$random[2]]; ?&gt;<br />&lt;?php echo $image_html[$random[3]]; ?&gt;<br />&lt;?php echo $image_html[$random[4]]; ?&gt;<br />&lt;?php echo $image_html[$random[5]]; ?&gt;<br />&lt;?php echo $image_html[$random[6]]; ?&gt;<br />&lt;/center&gt;<br />[/]<br />                 &lt;/td&gt;<br />&lt;td width="20%" align="right" class="welcome"&gt;<br />  &lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt;<br />&lt;input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"&gt;<br />&lt;input type="hidden" name="cmd" value="_xclick-subscriptions"&gt;<br />&lt;input type="hidden" name="business" value="chaos@emeraldforestseattle.com"&gt;<br />&lt;input type="hidden" name="item_name" value="Emerald Forest Seattle"&gt;<br />&lt;input type="hidden" name="item_number" value="EFS Subscription"&gt;<br />&lt;input type="hidden" name="no_note" value="1"&gt;<br />&lt;input type="hidden" name="currency_code" value="USD"&gt;<br />&lt;input type="hidden" name="a3" value="5.00"&gt;<br />&lt;input type="hidden" name="p3" value="1"&gt;<br />&lt;input type="hidden" name="t3" value="M"&gt;<br />&lt;input type="hidden" name="src" value="1"&gt;<br />&lt;input type="hidden" name="sra" value="1"&gt;<br />            &lt;/form&gt;<br />            &lt;b&gt;Hurry!&lt;/b&gt;<br />          <br /><br /> &lt;/tr&gt;<br />&lt;/td&gt;<br /> &lt;/table&gt; <br />&lt;br&gt;<br />&lt;/ br&gt;<br /><br /> 
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281022 - 10/25/04 08:27 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
argh I posted that before I got to read your post.<br /><br />Problem is I want to have the images displaying in the default header in the html include section so I have the first part in the ubbt_header.tmpl and this<br /></center><center><br /><?php echo $image_html[$random[0]]; ?><br /><?php echo $image_html[$random[1]]; ?><br /><?php echo $image_html[$random[2]]; ?><br /><?php echo $image_html[$random[3]]; ?><br /><?php echo $image_html[$random[4]]; ?><br /><?php echo $image_html[$random[5]]; ?><br /><?php echo $image_html[$random[6]]; ?><br /></center><br /> in the default header <br /><br />:will that not work?
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281023 - 10/25/04 08:59 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
I put the code in exactly like you decribed and it is not working. I have 6 banners and I want only one to display at a time.<br /><br />When setting the variable to one nothing displays
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281024 - 10/25/04 09:34 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Like I mentioned above, you need to convert the array into variables if posting into a template as opposed to echoing in a PHP script <img src="http://www.ubbdev.com/forum/images/graemlins/smile.gif" alt="" /> <br /> <br />So in your case it would look like this (I also gave a commented example in both sections for how to display 2 images instead of one in order to scale it up if needed)... <br /> <br />
Code:
 &lt;!-- &lt;? //UBBTREMARK --&gt; <br />// File Version 6.5 <br />[:"green"] <br />$image_html = array(); <br /> <br />// Insert the HTML code below for each image or banner in the pool (don't forget the \ before the ") <br />// You can also add individual ALT and TITLE tags if you wish <br /> <br />$image_html[0] = "&lt;a href=\"http://www.bajema.com\"&gt;&lt;img src=\"/ubbthreads/images/banners/bajbnr.jpg\" border=\"0\"&gt;&lt;/a&gt;"; <br />$image_html[1] = "&lt;a href=\"http://melancholic.net\"&gt;&lt;img src=\"/ubbthreads/images/banners/melancholicban.jpg\" border=\"0\"&gt;&lt;/a&gt;"; <br />$image_html[2] = "&lt;a href=\"http://www.decayingmadness.com\"&gt;&lt;img src=\"/ubbthreads/images/banners/decayingmadness.gif\" border=\"0\"&gt;&lt;/a&gt;"; <br />$image_html[3] = "&lt;a href=\"http://www.vixenshop.com\"&gt;&lt;img src=\"/ubbthreads/images/banners/vixshop.gif\" border=\"0\"&gt;&lt;/a&gt;"; <br />$image_html[4] = "&lt;a href=\"http://www.giger.com/mainflash.htm\"&gt;&lt;img src=\"/ubbthreads/images/banners/giger.jpg\" border=\"0\"&gt;&lt;/a&gt;"; <br />$image_html[5] = "&lt;a href=\"http://www.pitchfork.de/page_en.php?\"&gt;&lt;img src=\"/ubbthreads/images/banners/projectpitchfork.jpg\" border=\"0\"&gt;&lt;/a&gt;"; <br />$image_html[6] = "&lt;a href=\"http://emeraldforestseattle.com\"&gt;&lt;img src=\"/ubbthreads/images/happyhalloween.gif\" border=\"0\"&gt;&lt;/a&gt;"; <br /> <br />// Configure the number of unique images or banners to be displayed on the page <br />// It can be any number from 0-6 in the example given <br /> <br />$number_of_images = 1; // &lt;-- Configure <br /> <br />$random = array_rand($image_html, $number_of_images); <br /> <br />// Convert the array into variables for posting in a template <br />// The number of lines below is the *same number* specified by $number_of_images, in this case 1 <br />$image1 = $image_html[$random[0]]; <br />// $image2 = $image_html[$random[1]]; &lt;-- This is how it would look if using 2 images in $number_of_images, and so on <br />[/] <br />&lt;!-- echo &lt;&lt;&lt;UBBTPRINT --&gt; <br />&lt;!-- START OF header.tmpl TEMPLATE --&gt; <br />&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt; <br />&lt;html dir="{$ubbt_lang['READ_DIRECTION']}"&gt; <br />&lt;head&gt; <br />$headerinsert <br />$refresh <br />&lt;meta http-equiv="Content-Type" content="text/html; charset={$ubbt_lang['CHARSET']}" /&gt; <br />&lt;link rel="stylesheet" href="$stylesheet" type="text/css" /&gt; <br />&lt;link rel="shortcut icon" href="{$config['images']}/favicon.ico" /&gt; <br />$javascript <br />&lt;title&gt;{$config['title']}: $inputTitle&lt;/title&gt; <br />&lt;/head&gt; <br />&lt;body&gt; <br />&lt;!-- END OF header.tmpl TEMPLATE --&gt; <br />&lt;!-- UBBTPRINT --&gt; <br />&lt;!-- /* UBBTREMARK */ ?&gt; --&gt; <br /> 
<br /> <br /> <br />And here is my generic header
Code:
 &lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt; <br /> <br />&lt;title&gt;Emerald Forest Seattle &lt;/title&gt; <br /> <br /> <br /> <br />&lt;body bgcolor="#7b9b74"&gt; <br /> <br /> <br />&lt;center&gt;&lt;p&gt; <br />&lt;table border="0" cellspacing="0" cellpadding="0" width="100%"&gt;&lt;tr&gt; <br />&lt;td width="80%" align="center" valign="middle"&gt; <br />&lt;img src="/efsbanner.gif"&gt; <br /> <br /> <br />&lt;br&gt; <br />&lt;br&gt; <br />&lt;/td&gt; <br />&lt;/tr&gt; <br />&lt;/table&gt; <br /> <br />&lt;table border="0" cellspacing="1" cellpadding="2" width="95%"bgcolor="#000000"&gt;&lt;tr bgcolor="#7C8F79"&gt;&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt; <br /> <br />&lt;b&gt;&lt;a href="/faq.html" target="_new"&gt;Rules&lt;/a&gt;&lt;/b&gt;&lt;/td&gt; <br /> <br />&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="http://efs.stats.nuclearfallout.net"target="_new"&gt;Statistics&lt;/a&gt;&lt;/b&gt;&lt;/td&gt; <br /> <br />&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="http://216.254.1.196/~chaos/live1.6.html" target="_new"&gt;LiveStatus&lt;/a&gt;&lt;/b&gt;&lt;/td&gt; <br /> <br />&lt;td align="center" width="20%" background="/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="/efclan/staff.html" target="_new"&gt;Staff&lt;/a&gt;&lt;/b&gt;&lt;/td&gt; <br /> <br />&lt;td align="center" width="20%" background="http://emeraldforestseattle.nuclearfallout.net/attachments/64861-grad-02.gif"&gt;&lt;b&gt;&lt;a href="/Links.html" target="_new"&gt;Links&lt;/a&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt; <br />&lt;/table&gt; <br /> <br />&lt;br /&gt; <br /> <br />&lt;!--THIS PART GOES INTO THE GENERIC HEADER--&gt;&lt;div align="center"&gt;&lt;table width="100%" border="0" cellspacing="0" cellpadding="0"&gt;&lt;tr&gt;&lt;td align="center" valign="top"&gt; <br /> <br /> <br />        &lt;table border="0" cellspacing="1" cellpadding="2" width="95%" bgcolor="#000000"&gt; <br />          &lt;tr&gt; <br />          &lt;td width="20%" class="welcome"&gt; <br />            &lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt; <br />            &lt;input type="hidden" name="cmd" value="_xclick"&gt; <br />            &lt;input type="hidden" name="business" value="chaos@emeraldforestseattle.com"&gt; <br />            &lt;input type="image" src="http://emeraldforestseattle.nuclearfallout.net/ubbthreads/images/x-click-but04.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"&gt; <br />            &lt;/form&gt; <br />            &lt;b&gt;Send Money!&lt;/b&gt; <br />          &lt;/td&gt; <br /> <br />	  &lt;td width="60%" td bgcolor="#92A88E"&gt; <br />&lt;br&gt;&lt;/ br&gt; <br />&lt;center&gt;Welcome To The Forest&lt;/center&gt; <br />&lt;center&gt; <br />[:"green"] <br />&lt;/center&gt;&lt;center&gt; <br />$image1 <br />&lt;!-- $image2 --&gt; <br />&lt;!-- the 2nd image variable would go above if we were including 2 images --&gt; <br />&lt;/center&gt; <br />[/] <br />                 &lt;/td&gt; <br />&lt;td width="20%" align="right" class="welcome"&gt; <br />  &lt;form action="https://www.paypal.com/cgi-bin/webscr" method="post"&gt; <br />&lt;input type="image" src="https://www.paypal.com/en_US/i/btn/x-click-but20.gif" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!"&gt; <br />&lt;input type="hidden" name="cmd" value="_xclick-subscriptions"&gt; <br />&lt;input type="hidden" name="business" value="chaos@emeraldforestseattle.com"&gt; <br />&lt;input type="hidden" name="item_name" value="Emerald Forest Seattle"&gt; <br />&lt;input type="hidden" name="item_number" value="EFS Subscription"&gt; <br />&lt;input type="hidden" name="no_note" value="1"&gt; <br />&lt;input type="hidden" name="currency_code" value="USD"&gt; <br />&lt;input type="hidden" name="a3" value="5.00"&gt; <br />&lt;input type="hidden" name="p3" value="1"&gt; <br />&lt;input type="hidden" name="t3" value="M"&gt; <br />&lt;input type="hidden" name="src" value="1"&gt; <br />&lt;input type="hidden" name="sra" value="1"&gt; <br />            &lt;/form&gt; <br />            &lt;b&gt;Hurry!&lt;/b&gt; <br /> <br /> <br /> &lt;/tr&gt; <br />&lt;/td&gt; <br /> &lt;/table&gt; <br />&lt;br&gt; <br />&lt;/ br&gt; <br /> <br /> 
[/]
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281025 - 10/25/04 09:45 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
[]ChAoS said:<br />I put the code in exactly like you decribed and it is not working. I have 6 banners and I want only one to display at a time.<br /><br />When setting the variable to one nothing displays [/]<br /><br />Just hold on a couple minutes, lemme test.
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281026 - 10/25/04 10:09 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
Copied exactly as above produces this<br /><br />Welcome To The Forest<br />Happy Halloween<-this is a .gif that is hardcoded in and a banner should display below it<br />$image1
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281027 - 10/25/04 10:33 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
Yeah I think you're gonna need to use an include for this because the ubbt_template.tmpl file and the generic header file aren't related to one another. <br /> <br />I'll keep plugging away at to see if I can come up some kind of with a workable solution, and if so, I will post in this thread.
_________________________
Twisty []http://www.mameworld.info/misc/nana2.gif[/]
MAMEWorld

Top
#281028 - 10/25/04 10:39 PM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: smoknz28]
ChAoS_dup1 Offline
Code Monkey

Registered: 11/15/02
Posts: 576
Loc: Great Northwest
Thanks Twisty-I dont mind being the Guinea Pig hehe
_________________________
ChAoS
Emerald Forest Gaming Servers
Official STFU Thread


Top
#281029 - 10/26/04 04:18 AM Re: Finished-[All] Multiple Random Banners (No Duplicates) [Re: barbiro]
Twisty Offline
Code Monkey

Registered: 09/26/03
Posts: 524
It's time for another labotomy Chaos. Right then, forget everything else posted in this thread. This is a new approach, which is verified to work. <br /> <br />So here's what's involved...2 steps: <br /> <br />(see attachment, text file used so as to preserve the code spacing).


Attachments
122039-random_banners_for_chaos.txt (16 downloads)


Top
Page 1 of 2 1 2 >


Moderator:  Ian_W