Page 1 of 1

Generating dynamic navigation without MySQL

Posted: Tue Sep 20, 2005 4:18 pm
by mattcooper
Having finally created my dynamic site generator, I'm now looking for a way to generate navigation by means of a script which does the following:

1. Looks for directories in and under a specified start directory
2. Grabs the filenames of the documents in them (which have been dynamically generated with the filename as the final name to display as a link, minus the .php extension)
3. Displays the name of the folder as a button or button-styled table cell
4. When the button is clicked, either a flyout or a breadcrumb system is revealed with the names of the pages as links

I found a nice script here: http://www.apptools.com/phptools/dynamicsitemap.php which is kind of what I'm after, but not quite.

Can anyone suggest a script resource or any known method without using MySQL (for reasons of immediate portability)??

I'm really looking for an example of something that's already been coded, so I can strip it down and learn how to construct this type of navigation myself.

Thanks in advance guys.

Posted: Tue Sep 20, 2005 4:45 pm
by neophyte
This is where it starts:

Code: Select all

if ($handle = opendir('.')) {
   while (false !== ($file = readdir($handle))) {
       if ($file != "." && $file != "..") {
           echo "$file\n";
       }
   }
   closedir($handle);
}
After that you where it says echo $file, add your links and what not...

Hope that helps you get started.

Posted: Tue Sep 20, 2005 7:01 pm
by shoebappa
There's also a function called is_dir to see if the handle is a directory or not.

http://us2.php.net/manual/en/function.is-dir.php