Welcome to Geeklog, Anonymous Monday, September 25 2023 @ 04:20 pm EDT

Geeklog Forums

Random HTML Block

Status: offline


Forum User
Registered: 06/06/05
Posts: 13
I wanted a block that could display a random webcam image from a list of 20+ cams, so I wrote this custom function to achieve it. You can obviously use this for pretty much any html you like, not just cams, so it could be useful for displaying banners or any images you like.

Text Formatted Code
*Custom Block for displaying random html
function phpblock_randhtml ()
    $aHTML[0] = 'Put some html here';
    $aHTML[1] = 'Put some different html here';
    $aHTML[2] = 'Put even more html here';
    $aHTML[3] = 'Put yet more html here - add as many of these lines as you like, each with a different consecutive [number]';

    $iUpper = sizeof($aHTML) - 1;
    $iLower = 0;

    $iIndex = rand($iLower, $iUpper);
    return $aHTML[$iIndex];

It's pretty simple, but might be useful. Just add the code above to the end of your lib-custom.php, edit the code to add your desired html and create a new block calling the function phpblock_randhtml. You'll now have a block that displays a random selection from your various html lines - simple Very Happy

This block is used for the "Surfcam" block at cypry.com
cypry.com - dubs, drops and descents......

All times are EDT. The time is now 04:20 pm.

  • Normal Topic
  • Sticky Topic
  • Locked Topic
  • New Post
  • Sticky Topic W/ New Post
  • Locked Topic W/ New Post
  •  View Anonymous Posts
  •  Able to post
  •  Filtered HTML Allowed
  •  Censored Content