Previous Thread
Next Thread
Print Thread
Hop To
Joined: Oct 2008
Posts: 104
Member
Member
Joined: Oct 2008
Posts: 104
I use the custom islands to post advertising on our forums.

One of our clients wants to randomly rotate 3 ads.
I found a nice/simple php script to do the job.

But...
I'm not sure where to put the code to call the include (or the file containing the script).

I need to use this code to call in the script with the rotating ads...

<?
include_once("AdRotation.php");
echo "<div align='center'>$bannerAd</div>";
?>

And I need to make sure AdRotation.php resides in the right place to be called into the custom island.

Figured it was better to ask then to break things :-)

You can see it in action here (a test page I set up)...
http://www.pianoworld.com/RotateAdTest.php

Each time the page is reloaded, it randomly displays one of three ads.


Founder/Host
Piano World
https://PianoWorld.com
Home of the world famous Piano Forums.
http://forum.PianoWorld.com
88,000+ registered members
Over 2.5 million posts, and growing...
Joined: Dec 2003
Posts: 6,562
Likes: 78
Joined: Dec 2003
Posts: 6,562
Likes: 78
Okay for starters you can visit the faqs how do I forums here.
But basically you do not paste the <? or closing ?> in the php area in the island. It is already done by the script.


Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Joined: Oct 2008
Posts: 104
Member
Member
Joined: Oct 2008
Posts: 104
Great, thanks Ruben.

Headed for the FAQ now.


Founder/Host
Piano World
https://PianoWorld.com
Home of the world famous Piano Forums.
http://forum.PianoWorld.com
88,000+ registered members
Over 2.5 million posts, and growing...
Joined: Oct 2008
Posts: 104
Member
Member
Joined: Oct 2008
Posts: 104
Ok, so I read the tips.

It looks like I would need to put the entire php script into the section ...

/* PHP CODE HERE, IF NECESSARY */

--- Long PHP Script HERE with no opening/closing php tags ---

/* DO NOT CHANGE THE LINE BELOW */

Then call the script in here, something like this...

$body = <<<EOF

<div align='center'>$bannerAd</div>

EOF;
/* DO NOT CHANGE THE LINE ABOVE */

Am I understanding this correctly?



Founder/Host
Piano World
https://PianoWorld.com
Home of the world famous Piano Forums.
http://forum.PianoWorld.com
88,000+ registered members
Over 2.5 million posts, and growing...
Joined: Dec 2003
Posts: 6,562
Likes: 78
Joined: Dec 2003
Posts: 6,562
Likes: 78
Yea but you need to declare the value in the PHP section of the island. Then place the value in the eof section to display it.
So the php section will have $bannerAd=
Then the eof section will have $bannerAd


Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Joined: Dec 2003
Posts: 6,562
Likes: 78
Joined: Dec 2003
Posts: 6,562
Likes: 78
Not knowing the banner script.
I believe you need to delete the echo statement in the php section of the island also.


Blue Man Group
There is no such thing as stupid questions. Just stupid answers
Joined: Oct 2008
Posts: 104
Member
Member
Joined: Oct 2008
Posts: 104
It seems to work fine in the main part of our site, but when I put it into the island, it only pulls in the first banner in the list (as though it's not parsing through?).

Here is the entire code, including the Never Remove stuff for the ubb:

/* PHP CODE HERE, IF NECESSARY */

$bannerCounter= 1;

$bannerCode[$bannerCounter] = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'
width=\"125\" height=\"125\">
<param name='movie' value=\"http://www.m-audio.com/images/web/pianoworld_banners/125x125_1.swf\">
<param name='quality' value=\"high\">
<param name='bgcolor' value='#FFFFFF'>
<param name='loop' value=\"false\">
<EMBED src=\"http://www.m-audio.com/images/web/pianoworld_banners/125x125_1.swf\" quality='high' bgcolor='#FFFFFF' width=\"125\"
height=\"125\" loop=\"false\" type='application/x-shockwave-flash'
pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>
</EMBED>
</OBJECT></a>";

$bannerCounter++;

$bannerCode[$bannerCounter] = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'
width=\"125\" height=\"125\">
<param name='movie' value=\"http://www.m-audio.com/images/web/pianoworld_banners/125x125_2.swf\">
<param name='quality' value=\"high\">
<param name='bgcolor' value='#FFFFFF'>
<param name='loop' value=\"false\">
<EMBED src=\"http://www.m-audio.com/images/web/pianoworld_banners/125x125_2.swf\" quality='high' bgcolor='#FFFFFF' width=\"125\"
height=\"125\" loop=\"false\" type='application/x-shockwave-flash'
pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>
</EMBED>
</OBJECT></a>";

$bannerCounter++;

$bannerCode[$bannerCounter] = "<OBJECT classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0'
width=\"125\" height=\"125\">
<param name='movie' value=\"http://www.m-audio.com/images/web/pianoworld_banners/125x125_3.swf\">
<param name='quality' value=\"high\">
<param name='bgcolor' value='#FFFFFF'>
<param name='loop' value=\"false\">
<EMBED src=\"http://www.m-audio.com/images/web/pianoworld_banners/125x125_3.swf\" quality='high' bgcolor='#FFFFFF' width=\"125\"
height=\"125\" loop=\"false\" type='application/x-shockwave-flash'
pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash'>
</EMBED>
</OBJECT></a>";
$bannerCounter++;

$bannerAdTotals = $bannerCounter - 1;
if($bannerAdTotals>1)
{
mt_srand((double)microtime() * 1234567);
$bannerPicked = mt_rand(1, $bannerAdTotals);
}
else
{
$bannerPicked = 1;
}
$bannerAd = $bannerCode[$bannerPicked];

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

<div align='center'>$bannerAd</div>

EOF;
/* DO NOT CHANGE THE LINE ABOVE */



Founder/Host
Piano World
https://PianoWorld.com
Home of the world famous Piano Forums.
http://forum.PianoWorld.com
88,000+ registered members
Over 2.5 million posts, and growing...
Joined: Jun 2006
Posts: 16,299
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,299
Likes: 116
Well, the islands are cached; so it's possible it's just caching the output of it running once... Your best bet is having all that code in a php file and using an include() to include it in the custom island.


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Oct 2008
Posts: 104
Member
Member
Joined: Oct 2008
Posts: 104
Thanks Gizmo,

I do have it all in a file called AdRotation.php
The file is in the forum/ directory.

I don't know the correct syntax to pull it in though.

In a standard .php page it would be like this (but this doesn't work).

/* PHP CODE HERE, IF NECESSARY */



/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF

<?
include_once("AdRotation.php");
echo "<div align='center'>$bannerAd</div>";
?>

EOF;
/* DO NOT CHANGE THE LINE ABOVE */


Founder/Host
Piano World
https://PianoWorld.com
Home of the world famous Piano Forums.
http://forum.PianoWorld.com
88,000+ registered members
Over 2.5 million posts, and growing...
Joined: Jun 2006
Posts: 1,344
G
veteran
veteran
G Offline
Joined: Jun 2006
Posts: 1,344
This is what I do for my portal box and for ad island and it works wink

/* PHP CODE HERE */
$body = <<<EOF

<center>
<? php include("http://path_to/AdRotation.php"); ?>
</center>

EOF;

Joined: Jun 2006
Posts: 16,299
Likes: 116
UBB.threads Developer
UBB.threads Developer
Joined: Jun 2006
Posts: 16,299
Likes: 116
I THINK:

Code
/* PHP CODE HERE, IF NECESSARY */
include_once("AdRotation.php"); 

/* DO NOT CHANGE THE LINE BELOW */
$body = <<<EOF
<div align="center">$bannerAd</div>
EOF;
/* DO NOT CHANGE THE LINE ABOVE */

If you store the php file outside of the cache_builders/custom folder you'd need to just link to its path on the server in the include statement, ex:
/home/yoursite/public_html/forums/AdRotation.php


I am a Web Development Contractor, I do not work for UBBCentral. I have provided free User to User Support since the beginning of these support forums.
Do you need Forum Install or Upgrade Services?
Forums: A Gardeners Forum, Scouters World
UBB.threads: UBBWiki, UBB Styles, UBB.Sitemaps
Longtime Supporter & Resident Post-A-Holic
VNC Web Services: Code Modifications, Upgrades, Styling, Coding Services, Disaster Recovery, and more!
Joined: Oct 2008
Posts: 104
Member
Member
Joined: Oct 2008
Posts: 104
The only way I could seem to get it to work was put the full code back in the php section, call it in the $body, and set the cache for that custom island to 1 minute.

At least now it calls random ads after one minute.


Founder/Host
Piano World
https://PianoWorld.com
Home of the world famous Piano Forums.
http://forum.PianoWorld.com
88,000+ registered members
Over 2.5 million posts, and growing...

Link Copied to Clipboard
ShoutChat
Comment Guidelines: Do post respectful and insightful comments. Don't flame, hate, spam.
Recent Topics
Bots
by Outdoorking - 04/13/2024 5:08 PM
Can you add html to language files?
by Baldeagle - 04/07/2024 2:41 PM
Do I need to rebuild my database?
by Baldeagle - 04/07/2024 2:58 AM
This is not a bug, but a suggestion
by Baldeagle - 04/05/2024 11:25 PM
Is UBB.threads still going?
by Aaron101 - 04/01/2022 8:18 AM
Who's Online Now
0 members (), 476 guests, and 170 robots.
Key: Admin, Global Mod, Mod
Random Gallery Image
Latest Gallery Images
Los Angeles
Los Angeles
by isaac, August 6
3D Creations
3D Creations
by JAISP, December 30
Artistic structures
Artistic structures
by isaac, August 29
Stones
Stones
by isaac, August 19
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240430)