1. Skip Navigation |
  2. What's New |
  3. Search |
  4. Contact Me |
  5. This Site
29 November 2005   11:50 PM

After reading JonTan's Automatic Breadcrumb Creator Script on AccessifyForum, I thought hmm... what a neat idea.

So I unpacked my coding head, sat down and thought about it. I've just redeveloped my site. Wouldn't it be nice if rather than some static menu, the page automatically determines by itself where it is in my site and marks up the menu navigation accordingly? Yup, that'd be cool.

It can't be that difficult to do, can it?

Well, that depends. The draft that I use on the blogger part of my site wasn't. But this relies on a) knowing the part of the site these pages are found in and b) not marking up the actual hierarchy properly if you're looking at an archived post. But it does look at the rest of your directories. Or at least the ones I've specified in an array (so it doesn't spit out robots.txt etc). It will index the files it finds at the next level, but only manages to handle two directory levels. So far, so middling.

Well, it's a start. The next stage is to make it work recursively. This is more of a problem than I'd first envisaged because you don't know how many directory levels you've got, so you've got to create and use dynamically named variables. Which is where the whole pain in the arse thing comes in.

There's also the minor side issues of getting the damn thing to output valid XHTML and not spit out <ol> tags whenever it damn well pleases, but I've pretty much got there in the end. I'm currently in the process of documenting the procedure, in case it's of interest to anyone else and will include a link here when I'm finished.

Incidentally, if anyone else can follow the program logic, well done. I can just about work out what it's doing and I wrote the darn thing.

 

This page is powered by Blogger