Random banners on this forum

Dreamweaver & Flash (ahh ahhh) plus Web related Tutorials & Resources, HTML, CSS, PHP, Flash or whatever.
Post Reply
morphim
Site Admin
Posts: 609
Joined: January 5th, 2006, 2:21 pm
Location: Next Rock after the one Cow's at

Random banners on this forum

Post by morphim » January 30th, 2007, 11:27 am

OK. I've talked about this before but I'd still like to inplement a random banner script to this forum - one of a library of Citizen Art banners is randomly loaded every time a page is refreshed or loaded.

Any ideas? I found this (below) but don't know enough about it to say if it will work or where I would need to put it so it affects the whole forum. This example combines images and text. I'd just want the text. If anyone can help, I'd be very grateful. Cheers :D >>

<?php
function dodosrandgen() {
// set number of links you want to show at once
$show_link = 1;
// separate the links by, i.e. comma would be ",";
$separator = " ";
// Add links
// Please make sure you number entries CORRECTLY
// Look at the example for reference!
// DO NOT erase the priority part, leave all
// to 1 if you don't want them to have different
// priorities!


$links[0][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://regretless.com\" target=\"_blank\"><img src=\"regretless.gif\" border=\"0\" align=\"right\" width=\"75\" height=\"75\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a><font face=verdana size=1>regretless.com is dodo's collective domain where you can find all of her sites.</font></td></tr></table>";
$links[0][priority] = 1;
$links[1][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://pure-essence.net\" target=\"_blank\"><img src=\"pureessence.gif\" border=\"0\" align=\"right\" width=\"75\" height=\"75\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a><font face=verdana size=1>pure-essence.net is dodo's personal domain that shows who she is in real life and has her blog.</font></td></tr></table>";
$links[1][priority] = 1;
$links[2][link] = "<table width=\"250\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td><a href=\"http://board.regretless.com\" target=\"_blank\"><img src=\"dmb.gif\" border=\"0\" align=\"right\" width=\"75\" height=\"75\" style=\"filter:alpha(opacity=40)\" onMouseover=\"high(this)\" onMouseout=\"low(this)\"></a><font face=verdana size=1>dmb is dodo's popular message board. it's G rated and welcome all friendly members.</font></td></tr></table>";
$links[2][priority] = 1;


// HERE COMES THE BODY
if($links) {
for($i = -1; $i < count($links); $i++) {
for($j = 0; $j < $links[$i][priority]; $j++) {
$newlinksindex = count($newlinks) + 1;
$newlinks[$newlinksindex] = $links[$i][link];
}
}
} // end of if link exist

// debug
if($show_link >= count($newlinks))
$show_link = count($newlinks);

$showarray[0] = "";
$showindex = 0;
// Select a random element from the new array
do {
$randindex = rand(0, count($newlinks));
if(!in_array($newlinks[$randindex], $showarray) && $newlinks[$randindex] != "") {
$showarray[$showindex] = $newlinks[$randindex];
//print_r($showarray);
$showindex++;
}
}while(count($showarray) <= $show_link);

// finally print out
for($i = 0; $i < $show_link; $i++ ) {
if($show_link == 1 || (($i + 1) == $show_link))
print $showarray[$i];
else
print $showarray[$i].$separator;
}
//print_r($ranarray);
//print_r($links);
//print_r($newlinks);

} // end of the dodosrandgen function
?>
<html>
<head>
<title>dodosrandgen example 2</title>
<script language="JavaScript1.2">

/*
Gradual-Highlight Image Script-
© Dynamic Drive (www.dynamicdrive.com)
For full source code, installation instructions,
100's more DHTML scripts, and Terms Of
Use, visit dynamicdrive.com
*/

function high(which2){
theobject=which2
highlighting=setInterval("highlightit(theobject)",50)
}
function low(which2){
clearInterval(highlighting)
which2.filters.alpha.opacity=40
}



function highlightit(cur2){
if (cur2.filters.alpha.opacity<100)
cur2.filters.alpha.opacity+=5
else if (window.highlighting)
clearInterval(highlighting)
}

</script>
</head>
<body bgcolor="black" text="white" link="pink" vlink="pink" alink="pink">
I want to demonstrate here how you can combine image and words as well as javascripts with my script. I used the gradual image script from <a href="http://www.dynamicdrive.com/dynamicinde ... m">here</a>. I put a table for each link since each of them will only show up once.
<br><br>
<center>
<?dodosrandgen();?></center>
</body>
</html>
It's always a sunny day above the clouds : )

Post Reply