I'm using an auto-listing file script to create a quick content menu in list format. Here it is:
Code:
<?php
$dh = opendir('/home/www/'.$_SERVER['HTTP_HOST']);
echo '<ul><li><a href="index.php">Home</a></li>';
while ($file = readdir($dh)) {
// pages and directories to ignore
if ($file!='.' && $file!='..'
&& $file!='template'
&& $file!='scripts'
&& $file!='index.php'
&& $file!='gallery.php'
&& $file!='videos.php'
)
{
$file_array[] = $file;
}
}
sort ($file_array);
foreach($file_array as $value) {
echo '<li><a href="'.$value.'">'.$value.'</a></li>';
}
if($gallery_page=='enabled'){echo '<li><a href="gallery.php">Gallery</a></li>'; }
if($videos_page=='enabled') {echo '<li><a href="videos.php">Videos</a></li>'; }
echo '</ul>';
closedir($dh);
?>
Within the "// pages and directories to ignore" part, I've set the index.php, gallery.php and videos.php pages to be excluded from the array listing.
This is because the home page is referenced and echo'd right at the top of the listing and the gallery and videos page is referenced and echo'd at the bottom and are dependant on whether I have them "enabled" in my user config file.
Everything works fine as it is but I would like to fine-tune the position of some of my list items.
What I would like to do is include the gallery and videos page in the array, so they are sorted alphabetically along with all the other pages in my home directory, but I dont know how.
I only need to include them in the array if the config file says "enabled", as per the last few lines. Can somebody please offer some assistance.
Thanks
Beverley
Bookmarks