Generating dynamic navigation without MySQL

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
mattcooper
Forum Contributor
Posts: 210
Joined: Thu Mar 17, 2005 5:51 am
Location: London, UK

Generating dynamic navigation without MySQL

Post 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.
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post 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.
User avatar
shoebappa
Forum Contributor
Posts: 158
Joined: Mon Jul 11, 2005 9:14 pm
Location: Norfolk, VA

Post 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
Post Reply