Site Links
Home
Features
Documentation
Pricing & Order
Members Area
Support Options
UBBDev.com
UBBWiki.com
Who's Online
3 registered (57-Vette, Chosen, Stan), 39 Guests and 15 Spiders online.
Key: Admin, Global Mod, Mod
Featured Member
Registered: 10/19/08
Posts: 52
Top Posters (30 Days)
Ruben 50
DennyP 24
Gizmo 23
Dunny 15
SteveS 13
AllenAyres 12
dbremer 10
SD 10
drkknght00 9
doug 8
Latest Photos
OK Corral Shoot Out
Testing
Basildon Train Station
Basildon Town Centre looking from the rounderbout
Basildon Town Square
Page 1 of 3 1 2 3 >
Topic Options
#235139 - 02/25/10 06:56 PM Custom Island - Banner rotation Code
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
This is what I have inserted into Custom Island, using this ad Ad Island.

Quote:
/* PHP CODE HERE */

/* BODY HERE */
$body =
$bannerAd[1] = 'http://www.germanshepherdhome.net/testadbanner1.jpg';
$bannerAd[2] = 'http://www.germanshepherdhome.net/testadbanner2.jpg';
$bannerAd[3] = 'http://www.germanshepherdhome.net/testadbanner3.jpg';

$adCount = count($bannerAd);
$randomAdNumber = mt_rand(1, $adCount);
echo $bannerAd[$randomAdNumber];
<<<EOF
EOF;


So that shows up is just the url


What did I do wrong??? Some day I will learn php

Val
_________________________
http://germanshepherdhome.net
Top
Express Hosting
Express Hosting "We are the official hosting company of UBB.threads. Ask us about our free migration services to migrate your UBB.threads installation."
#235140 - 02/25/10 07:15 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
gliderdad Offline
Registered: 06/08/06
Posts: 1466
Loc: NY
You need to put the code between the

<<<EOF

EOF;

So you should be

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

$bannerAd[1] = 'http://www.germanshepherdhome.net/testadbanner1.jpg';
$bannerAd[2] = 'http://www.germanshepherdhome.net/testadbanner2.jpg';
$bannerAd[3] = 'http://www.germanshepherdhome.net/testadbanner3.jpg';

$adCount = count($bannerAd);
$randomAdNumber = mt_rand(1, $adCount);
echo $bannerAd[$randomAdNumber];
EOF;
Top
#235141 - 02/25/10 07:27 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
SD Offline
Registered: 04/19/07
Posts: 4056
Loc: SoCal, USA
Php Code:
/* PHP CODE HERE */

$Ads = array (
	'http://www.germanshepherdhome.net/testadbanner1.jpg',
	'http://www.germanshepherdhome.net/testadbanner2.jpg',
	'http://www.germanshepherdhome.net/testadbanner3.jpg'
	);


/* BODY HERE */
$body = <<<EOF
 $Ads[mt_rand(0, count($Ads)-1)]
EOF; 


might work

Remember array index starts from 0 there wink

Also, i'd recommend (if i were you) to put your banners in something like /forums/images/banners directory. That way you don't clutter up your site's root dir.. if you do, you'd need to modify the URLs above, but you get the drift smile
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
#235142 - 02/25/10 08:25 PM Re: Custom Island - Banner rotation Code [Re: SD]
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
SD,

I did copy and paste on your code got this error

Quote:
Parse error: parse error, unexpected $ in /home/content/t/i/g/tiger2/html/germanshepherdhome/forum/cache_builders/custom/portal_box_1.php on line 16
_________________________
http://germanshepherdhome.net
Top
#235143 - 02/25/10 08:28 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
Gliderdad, I copied and pasted the code you posted and all I get the Island box is

Quote:
= 'http://www.germanshepherdhome.net/testadbanner1.jpg'; = 'http://www.germanshepherdhome.net/testadbanner2.jpg'; = 'http://www.germanshepherdhome.net/testadbanner3.jpg'; = count(); = mt_rand(1, ); echo ;
_________________________
http://germanshepherdhome.net
Top
#235144 - 02/25/10 08:42 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
SD Offline
Registered: 04/19/07
Posts: 4056
Loc: SoCal, USA
yah, i left off a ')'

updated the post now..

i keep forgetting to match the number of ('s to )'s and arrays use [] too! laugh
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
#235145 - 02/25/10 08:50 PM Re: Custom Island - Banner rotation Code [Re: SD]
gliderdad Offline
Registered: 06/08/06
Posts: 1466
Loc: NY
SD's is correct not mine, forgot to move the php to where it should be
Top
#235146 - 02/25/10 08:55 PM Re: Custom Island - Banner rotation Code [Re: gliderdad]
SD Offline
Registered: 04/19/07
Posts: 4056
Loc: SoCal, USA
Custom island syntax has been a bugaboo, because it's not obvious what is php and what is not..

In actuality, the ENTIRE code block is, since the custom island code that UBB.threads uses to save it simply puts <?php and ?> around it.

The only thing you MUST have in your code is the last 3 lines.. where 1 of them assigns to the body a value. the EOF; is key too, since the save code keys upon it.

Linky Poo to a tutorial in progress about how it works.. that one is for a different application of custom island, but the concept remains the same smile
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
#235147 - 02/25/10 09:38 PM Re: Custom Island - Banner rotation Code [Re: SD]
Wisc.Tiger Offline
journeyman
Registered: 07/30/07
Posts: 93
Loc: WI
SD,

Another error message
Quote:
Parse error: parse error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting ']' in /home/content/t/i/g/tiger2/html/germanshepherdhome/forum/cache_builders/custom/portal_box_1.php on line 13
_________________________
http://germanshepherdhome.net
Top
#235149 - 02/25/10 10:05 PM Re: Custom Island - Banner rotation Code [Re: Wisc.Tiger]
SD Offline
Registered: 04/19/07
Posts: 4056
Loc: SoCal, USA
Php Code:
# Le Pee H Pee
$Ads = array (
	"http://www.germanshepherdhome.net/testadbanner1.jpg",
	"http://www.germanshepherdhome.net/testadbanner2.jpg",
	"http://www.germanshepherdhome.net/testadbanner3.jpg"
	);

$adNum = mt_rand(0, count($Ads)-1);

# The body!
$body = <<<EOF
 <img src="{$Ads[$adNum]}" />
EOF; 


Try that. I typed it up too quick smile

I put it on my test site for you to see Linky Dinky
_________________________

Threads tutorials . Threads & Wordpress experts . UBB resume

If I you, click this link as to why
Top
Page 1 of 3 1 2 3 >



Moderator:  AllenAyres, Harold, Ian, Ron M 
Shout Box

Today's Birthdays
No Birthdays
Recent Topics
Temporary Password email not being received
by
05/24/12 10:02 PM
Ability to "like" individual posts (not Facebook "likes)
by doug
05/23/12 09:03 AM
Island Permissions
by ThreadsUser
05/22/12 03:03 PM
streaming video
by prkrgrp
05/20/12 07:02 PM
New Posts Corrupted? Can someone help?
by PianoWorld
05/19/12 09:41 AM
Forum Stats
10492 Members
36 Forums
33842 Topics
181709 Posts

Max Online: 978 @ 06/24/07 11:19 PM
Random Image