Click to See Complete Forum and Search --> : AutoNav (Automated Navigation)


rpanning
11-14-2003, 09:22 PM
Hi, this script automaticly makes your navigation lists based on the files in the filesystem. I'm looking for any input to improve it, expecialy speed since it scans dirs, but any input is great. Note that I do have a cache system setup but it's not apart of AutoNav. I hope you find this script helpful, let me know if you use it! :D Below is kind of a Q&A section. The file is attached.

Why was it made?
I'm the "unofficial Webmaster" for our website at work and we have some people updating the content. Every once and a while they would make a new page. Sometimes they wouldn't tell me and sometime they would. So, I was getting sick of having to look for navigation changes, added pages. Also, it's a PAIN having to update almost every page. So I made this script/class so I would never have to update the navigation.

How does it list?
It will scan your webpages from the cwd back to the doc root. It's then sorted to get the proper sequense. All pages and folders starting with a underscore are hidden. The link title is based on the filename or foldername if it's an index file. All files with the link extenstion are used to get the link to another page. The root file is used to get the name of the root link (top link, '/').

How does it work?
When you make a new AutoNav instance it sets the default values. Next, when you make the nav list it will read through the dirs. (Note: All files and folders starting with _ are NOT listed.) When it reaches the .. folder it goes back and lists that, until the document root is reached. If it reaches a folder, the folder is checked for an index file and listed if one exists. Next, if it reaches a file that has the extension in the extension list or link extension the type is checked. If it's an index AND the current dir is the doc root it checks to see if the / url is already added, if so it returns. If not the root file is included to get the new name (output buffering is used to catch extra whitespace). It's then added to the list. If it's a link file, file is also included to get the URL. (Note: The name is set before the file is included so that you can change it before adding it to the list.) If it's a regular file its added to the list. Finaly, when you display the nav list it is sorted by URL to get the proper sequense and then printed.

What do I have to do to use it?
There are a few things that you might want to change so that it works with your site. First, make sure the default values are correct for your site (ext and index lists, link ext, and root file). Next, you'll want to change the output code, look in displayNav_List for this. Look at all of the $output variables, that's what will be printed. Change the indent size and style if you want. Finaly, make sure you do something with the errors. I have my own error handling I use that displays the errors on the page if there are any (not the one thats in the attached file ;)). Then make a new AutoNav and makeNav_List() then displayNav_List(). Other than that you should be set to go, unless you want to make some tweeks. Don't forget to make the root file and any links you want.

jenni
11-18-2003, 04:20 PM
To be honest, I am more interested in seeing your company's website...I can't imagine maintaining a site (especially a business site) where anyone and everyone can add pages on a whim without letting the webmaster (official or unofficial) know about it.

rpanning
11-18-2003, 06:27 PM
I work for a school district and my job is to fix the computers. The Website is done on my "free time" and since I don't have much of that my boss has decided to split up the work. Each building keeps their own site content up-to-date. There for I don't see every change, addition, etc. We are a growing district so I'm sure sometime in the future we'll have a full-time Webmaster but until then this script helps out a lot with navigation.

Also, I'm going to start working on version 2 of AutoNav. I've though of a few different ways to code it. Still looking for some input. :)

Auto_Nav version 2 will be for PHP 5 and contain major new features. It will be completely rewritten so look for it sometime in spring 2005.

planetsim
11-19-2003, 12:30 AM
I may just suggest that i got your script. however got the following errors with it.


Warning: asort() expects parameter 1 to be array, null given in D:\httpdocs\autonav.php on line 139

Warning: Invalid argument supplied for foreach() in D:\httpdocs\autonav.php on line 140

Warning: Invalid argument supplied for foreach() in D:\httpdocs\autonav.php on line 143


Now i didnt modify the script. But as a suggestion maybe make sure your script is portable. Now for all i know i may have not set it up correctly. But keep errors on this will allow you to see all errors, than when you wish to distribute it or use it on a different system there should be no bugs.

just me 2cents