MyBB Community Forums

Full Version: Randomizing the logo.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I wanted to know if we could randomize the logo at the top left.I mean showing more than 2 images.So everytime one opens the site there is a different logo.Is it possible?Please tell me how if it is possible.

Tristam
Hello doesn't anyone know about this.
http://www.gfx-depot.com/forum/showthread.php?tid=814

It's the same principle.
When you made the php file, just go to Admin CP and change the Forum logo to the php page you made.
It's very easy. It's just like a banner rotator for every page load.
You can try this code
<?php
// +---------------------------------------------+
// |     Using by User						 |
// |     http://www.thanhquang.info				 |
// |	 Open source 'n' free					 |
// +---------------------------------------------+


$pix_va = array();
$store_va = opendir('images/');

while($file_va = readdir($store_va))
{
  $exp_va = substr($file_va, -4);

  if(($exp_va == '.gif') || ($exp_va == '.jpg') || ($exp_va == 'jpeg') || ($exp_va == '.png') )
  {
    $pix_va[] = $file_va;
  }
}

$numpix_va = count($pix_va) - 1;
$random_va = rand(0, $numpix_va);

// td close tag is put here so that Explorer doesn't add an extra 2 pixels to the bottom of the image
echo '<img src="images/' . $pix_va[$random_va] . '"/>';

?>

Remember creat images folder
I use javascript to do this at finalfantasyforum.com where I rotate about 12 banners.  Smile

You can view it as an example and use the code. It's from dynamic drive.  Using javascript makes it easy.

Put this into your headerincludes template (change to reflect your images).
<!--// Begin

var theImages = new Array() // do not change this

theImages[0] = 'images/logos/1.jpg'
theImages[1] = 'images/logos/2.jpg'
theImages[2] = 'images/logos/3.jpg'
theImages[3] = 'images/logos/4.jpg'
theImages[4] = 'images/logos/5.jpg'
theImages[5] = 'images/logos/6.jpg'
theImages[6] = 'images/logos/7.jpg'
theImages[7] = 'images/logos/8.jpg'
theImages[8] = 'images/logos/9.jpg'
theImages[9] = 'images/logos/10.jpg'
theImages[10] = 'images/logos/11.jpg'
theImages[11] = 'images/logos/12.jpg'
theImages[12] = 'images/logos/13.jpg'


var j = 0
var p = theImages.length;
var preBuffer = new Array()
for (i = 0; i < p; i++){
   preBuffer[i] = new Image()
   preBuffer[i].src = theImages[i]
}
var whichImage = Math.round(Math.random()*(p-1));
function showImage(){
document.write('<img src="'+theImages[whichImage]+'" border="0" alt="Final Fantasy Forums Logo">');
}

//  End -->
</script>

Then change your header template...replace the img tag for the logo with this:

<script language="Javascript" type="text/javascript">
<!--
showImage();
//-->
</script>