just for fun, i mocked up a little prototype
here. the start page is hardcoded. the images will take you to a subdirectory and run showdir.php with the URL of the subdirectory as an argument.
showdir.php will parse the directory and perform the following:
1. if it finds a file, it will assume it's an image and display it
2. if it finds a subdirectory, it will make a link to the subdirectory
so, if you click on the link, it calls showdir.php again, but with the new value. the best example of this is the bricks, you can follow that down a couple directories.
it's not the best code, or the best way to do it, but it's a working prototype. here's the php code:
showdir.php:
PHP:
<?
//----------------------------------------------------------------
//
// %Z%%M% %I% %G%
//
// copyright Steve Zimmers 2006
//
//----------------------------------------------------------------
include "header.inc";
include "style.css";
?>
<body>
<?
//------------------------------------------------------------
// display_image
//------------------------------------------------------------
function display_image($file, $dir)
{
$pathed_file = $dir . "/" . $file;
$img_string = '<img src="' . $pathed_file . "\" " . 'width="200" height="150" />';
echo $img_string . '<br />' . '<br />' . "\n";
}
//------------------------------------------------------------
// make_url
//------------------------------------------------------------
function make_url($file, $dir)
{
$pathed_file = $dir . "/" . $file;
$href_string = '<a href="showdir.php?display_dir=' . $pathed_file . "\"" .'>' . $file . '</a>';
echo $href_string . '<br />' . '<br />' . "\n";
}
//------------------------------------------------------------
// main
//------------------------------------------------------------
// display_dir is our passed in variable. first we change to
// that directory in order to grab the file contents
chdir($display_dir);
// next we create our directory object in order to get
// the file list
$dir = dir('.') or die($php_errormsg);
// process each file
while (false !== ($f = $dir->read()))
{
// skip this directory and its parent
if ($f == "." || $f == "..")
continue;
// if it's a file, assume it's an image to display
if (is_file($f))
{
display_image($f, $display_dir);
continue;
}
// if it's a directory, make an href
if (is_dir($f))
{
make_url($f, $display_dir);
continue;
}
} // while
// clean up
$dir->close();
?>
</body>
<?
include "footer.inc";
?>
index.php:
PHP:
<?
include "header.inc";
include "style.css";
?>
<body>
<a href="showdir.php?display_dir=images/chairs">
<img src=images/chairs.jpg width="200" height="150" />
</a>
<br />
<br />
<a href="showdir.php?display_dir=images/bricks">
<img src=images/bricks.jpg width="200" height="150" />
</a>
<br />
<br />
<a href="showdir.php?display_dir=images/trees">
<img src=images/trees.jpg width="200" height="150" />
</a>
</body>
<?
include "footer.inc";
?>
header.inc:
PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>silly</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
footer.inc:
style.css is empty.