not too sure if you can do this unless you have another script using the tag {PHP:yourscript}
here is a script that might help
you can create a directory with your files that you want to randomize, then call this file below randomizer.php place in structure one higher
eg. /2/cms/mods/random/randomizer.php
then include the randomizer as a php tag from phpWCMS
hope this helps
TriP
Code: Select all
<?
//***************EDIT FROM HERE*********************
//Any directory name should end by the trailing "/"
$directoryName = ($_SERVER['DOCUMENT_ROOT']."/2/cms/mods/random/dir/");
//replace the "./" by the name
// of the directory where your pages are placed, note that the trailing "/" is mandatory
// Note that this should be a relative path to the directory where this file is located
//
$pageExtension=".html";// in this case, we are randomly displaying .html files (note the ".")
// note that all pages you want to randomly display should have the same extension
// In the directory specified above by the variable "$directoryName", you can put just anything...
// from images to movies, other subdirectpries....etc.... just anything.... but,
// make sure that the files you want to display randomly are the only one in that directory
// having the extension (in this example ".html") .... so you put there only ".html" files that
// you want to display randomly..... and can add other non .html files as well
// You may change the $pageExtension variale to ".php" , ".htm" or what ever ... but then, all that
// type of file will be randomly displayed!
//
/*
********************* STOP EDITING HERE ***********************************
*
* aaPHPrandomPage, version 1.0
* August 2002, Arcadius Ahouansou.
* for any comment or suggestion please email me at: ahouans@users.sourceforge.net
* A simple function for displaying random images and flash movies.
* a working demo of this script is running at:
* http://ahouans.sh.cvut.cz/projects/aaPHPrandomPage/
********************************************************************************/
function displayAaPHPrandomPage($dirname, $extension){
$dirhandle = opendir($dirname) or die("ERROR opening ".$dirname);
while (false !== ($file = readdir($dirhandle))) {
global $SCRIPT_NAME ;
if ( !@is_dir($file) && (substr_count($file,$extension) !=0) && ( substr_count($SCRIPT_NAME,$file)==0)) {
$filelist[] = $file;
}
}
closedir($dirhandle);
srand((double)microtime()*1000000);
$pageNumber = rand(0, sizeof($filelist) - 1);
$pageName=$dirname.$filelist[$pageNumber];
include($pageName);
return ;
}
?>
<?=displayAaPHPrandomPage($directoryName, $pageExtension)?>