+39 333 8580702

Randomize snippet

Ho pubblicato qui:, lo snippet che utilizzo per generare immagini casuali nell’intestazione di questo sito.

Lo potete trovare anche nella Snippet Library del sito ufficiale di Etomite CMS e potete discuterne nel forum di Etomite.

PS: In questo post e nella pagina in cui ho pubblicato lo snippet potete testare il futuro template del mio sito.

UPDATE 12/07/2008

Ecco qua il codice dello snippet:

//Snippet name: Randomize
//Version 1.0
//Tested with Etomite 0.6.1
//Created by scox -
//Distribuited under a by-nc-sa CC licence: //
//This snippet take a random image from a given directory.
//The output is the url of the image, so you can use it on a img tag or for a background.
//The only thingh you have to change is the $dir variable.

//Example:<img src=”[ !Randomize!]” alt=”Head” width=”750″ height=”100″ />

function GetDirArray($sPath) {
while ($file = readdir($handle))
if ($file != “.” && $file != “..” && (ereg(“.jpg”, $file) || ereg(“.gif”, $file))) $retVal[count($retVal)] = $file;
return $retVal;

/* $dir is the folder where you put the images that you want in your random sequence, change only this in the snippet */


$index=rand(0, count($file)-1);
$output= “$dir/”.”$file[$index]”;

return $output;


  1. werutzb-Reply
    8 Ottobre 2008 at 3:03


    I would like make better my SQL capabilities.
    I red really many SQL resources and want to
    read more about SQL for my occupation as db2 database manager.

    What would you recommend?


  2. Samiamtoo-Reply
    4 Maggio 2009 at 20:44

    sam i am

  3. Gundeflan-Reply
    9 Giugno 2009 at 21:37

    I want to listen good music. Help me please.

  4. goodcamimmick-Reply
    11 Giugno 2009 at 13:35


    What are the best dedicated server web hosting company?

    I’m trying to set up a web site for my new business.

    thank you in advance,


Leave A Comment

%d blogger hanno fatto clic su Mi Piace per questo: