TinyPortal

Development => Block Codes => Topic started by: MTF95 on May 31, 2008, 06:38:54 PM

Title: [Request] Bottom block - Random advertise + banner
Post by: MTF95 on May 31, 2008, 06:38:54 PM
Hi!

Can anyone create a PHP code which shows a random banner + a short text for each of them that I can use in a bottom panel?
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: JPDeni on May 31, 2008, 06:47:12 PM
Random stuff is really simple. First, come up with the html for each thing you want. Something like:


<img src="http://url.to.somedomain/images/image.jpg"><br />Text to go below that image


Then stick them all into an array, randomize the array, and display the top one.


$stuff= array (
        '<img src="http://url.to.somedomain/images/image.jpg"><br />Text to go below that image',
        '<img src="http://url.to.someotherdomain/images/otherimage.jpg"><br />Text to go below that other image',
  );

shuffle($stuff);

echo $stuff[0];


It'll randomize however many you put in, so if you want one to show up more often than others, you'll need to put it in multiple times.
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: MTF95 on May 31, 2008, 06:50:02 PM
Thank's!
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: MTF95 on May 31, 2008, 07:02:36 PM
I just get a block showing "Array"
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: JPDeni on May 31, 2008, 07:14:13 PM
Sorry. My fault. I changed my mind halfway through writing the code. Try the new code.
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: MTF95 on May 31, 2008, 07:22:11 PM
Thank's! :)
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: MTF95 on May 31, 2008, 07:59:15 PM
One more question:
Now when this works, where can I find a fairly big TP banner to have there?
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: IchBin on May 31, 2008, 08:18:24 PM
Pretty much anything you have a questions about has already been posted. Even random rotating banners has been posted 10 times at least. Feel free to use the search button here for your questions. You'll even find some banners that were posted quite some time ago.

http://www.tinyportal.net/index.php?topic=5091.0
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: Reality12 on June 13, 2008, 07:13:07 AM
i got an error.

i set it as a scriptbox.

see image below.

(https://www.tinyportal.net/proxy.php?request=http%3A%2F%2Fwww.picattic.com%2Ffiles%2Fjvm9sdba9r9q3bskiz29_thumb.jpg&hash=c82db94acd43c0b2eb2ca2cacef481f5f79c2d47) (http://www.picattic.com/viewer.php?file=jvm9sdba9r9q3bskiz29.jpg)

it's on the left, under "MARKETS."

this is what i am doing:

$stuff= array (
        '<a target="new" href="http://www.url.com/directory/image.jpg"><img src="http://www.url.com/directory/image.jpg" width"180" height="170"></a>',
        '<a target="new" href="http://www.url.com/directory/image1.jpg"><img src="http://www.url.com/directory/image1.jpg" width"180" height="170"></a>',
  );

shuffle($stuff);

echo $stuff[0];


where did i go wrong?
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: MTF95 on June 13, 2008, 08:24:57 AM
It should be a PHP block.
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: Reality12 on June 13, 2008, 03:24:56 PM
that seems to have done it.

thank you. :)
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: Reality12 on June 13, 2008, 06:50:54 PM
two more things...

i'd like the images centered.

adding an html 'center' code, doesn't work.

can someone advise?

second. the width of the images don't seem to change, no matter what i do.

any clue?
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: JPDeni on June 13, 2008, 07:42:55 PM
Quoteadding an html 'center' code, doesn't work.

It should. You didn't tell us what you tried and what "doesn't work" means, but I'll tell you one way that I know works:


echo '<center>';
echo $stuff[0];
echo '</center>';


Quotesecond. the width of the images don't seem to change, no matter what i do.

What have you done? It should work just fine if you add height and width attributes to the img tag.
Title: Re: [Request] Bottom block - Random advertise + banner
Post by: Reality12 on June 13, 2008, 08:02:55 PM
i was using '<center>' and '</center>'.

one at the very top, and the other at the very end.

regarding the height and width, i just realized my mistake...

i was using:

width"152" height="170"

but as you can see, there was an oversight.

it should have been:

width="152" height="170"

thanks again JPDeni. :)