free-info-central blog

… not your ordinary infomercial …



A snippet-rotator for people using The Article System

23rd January 2006

If you’re using the Article System, this piece of code might come in handy for you. In the first manual i downloaded for it, it said they would show a way to include the article-snippets on the index-page, but that never happened, so I managed to hack something up myself. Notice: this isn’t pretty, but it seems to do the trick :D

It should reside in the same directory as your snip_*.html-files, and a smart thing would be to rename your index-files to .shtml and put <[REMOVETHIS]!--#include virtual "randomsnippet.php" --> where you want the snippet to appear. Please put a nicely formatted paragraph-wrapper or something around that statement or it will look like shite! :D

—-< randomsnippet.php >—-

function getRandomFile($prefix)
{
$dir = opendir(’.');
while (($myfile = readdir($dir)) !==false)
{
if ($myfile != ‘.’ && $myfile != ‘..’ && is_file($myfile) && $myfile != ‘resource.frk’)
{
if(ereg(”^$prefix”, $myfile))
$files[] = $myfile;
}
}
closedir($dir);
srand ((float) microtime() * 10000000);
$file = array_rand($files);
return $files[$file];
}
$display = getRandomFile(”snip_”);
include($display);
?>

—-< randomsnippet.php >—-

That’s it. Enjoy. I’m not charging you for it :)

One Response to “A snippet-rotator for people using The Article System”

  1. Eric’s Tips » Blog Archive » Free Snippet Rotator For Article System Users Says:

    […] http://blog.free-info-central.com/2006/01/23/a-snippet-rotator-for-people-using-the-article-system/ […]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>