SimplePortal
Customization => Blocks and Modifications => Block Requests => Topic started by: shawn on October 08, 2012, 12:59:54 PM
-
Hey all,
Is there an easy way to use the PHP block to add a banner rotation for advertising? I want to add 2 banners to rotate during each page view on a header block.
-
Try this:
function RandomCode ($array)
{
$total = count($array);
$call = rand(0,$total-1);
return $array[$call];
}
$html = array (
'<a href="#">Link1</a>',
'<a href="#">Link2</a>'
);
echo ''.RandomCode($html).'';
I found this on my FTP, works nice :)
Replace <a href="#">Link1</a> and <a href="#">Link2</a> with your HTML code.
-
phantomm, thank you VERY much! That worked perfectly. :)
-
ok...I am so new at this stuff! My site has been live for almost two weeks and I am learning as I go. So my question is, where do you enter that code and what do you need to do to make it function
-
That is php code. so you would put that in a custom php block.
But that code is not complete. Link1 and Link2 would probably be replaced by your desired image banner, and you would need to replace the "#" with the actual URL you want the link to go to.
-
OK so I applied the code. But how do I add images instead of just text with a link to the image. I suppose image tags of some sort but where do I put them. It works, but it only displays text that can be clicked on
-
use
function RandomCode ($array)
{
$total = count($array);
$call = rand(0,$total-1);
return $array[$call];
}
$html = array (
'<a href="#"><img src="URL_TO_IMAGE" alt="" /></a>',
'<a href="#"><img src="URL_TO_IMAGE" alt="" /></a>'
);
echo ''.RandomCode($html).'';
-
use
function RandomCode ($array)
{
$total = count($array);
$call = rand(0,$total-1);
return $array[$call];
}
$html = array (
'<a href="#"><img src="URL_TO_IMAGE" alt="" /></a>',
'<a href="#"><img src="URL_TO_IMAGE" alt="" /></a>'
);
echo ''.RandomCode($html).'';
Thank you. Works great!
-
Hello,
If i want this to <p align="center"> how do i then do that ?
Brian
-
echo ''.RandomCode($html).'';
echo '<p align="center">'.RandomCode($html).'</p>';
-
Thanks that looks way better ;D