Found 1 entry.
You'd think that menus would be easy. After a good 5 or 6 hours, I've polished them off.
It's funny because some of the things you'd think would be easy take a little longer than you'd expect. Menus for instance.
The one thing menus have is order. Content managed pages don't have order since they're like a hash (yes, this is Perl). News and blogs have an order but that is implicit because of the current_timestamp. Menus have both an implicit order (the order they were put in) and an explicit order (the order the user has re-arranged the items to).
Anyway, in doing the algorithm to figure out which two display fields I had to swap round was a bit of hassle but I got there in the end. Then again, I was (am?) tired, so that didn't help. Moving on...
The menu is a simple list with each item having an integer level. This means I don't have to deal with hierarchical data - in a relational database - so that makes it a little easier. It also means it's really easy to figure out what you want your HTML to do at each level.
As an example, over at KiwiWriters, we only have a 2 level menu. If the level is one, then it is a top-level menu. My implementation writes out each <div> and only puts an extra class on it (to indent it) if the level > 1. As an added trick, if the level == 0, it isn't shown! Nice to hide those Coming Soon pages :-)
Even though the above workings of the menu are simple, it can pretty much accommodate a number of menu systems I have come across in the past. Also, the way Zaapt is designed, means that if someone wants to come along and create AnotherMenu, a HierarchicalMenu or even a SuperWhizzBangMenuWhichGlowsInTheDarkMenu, then that's perfectly fine with me.
Implementations at the ready...!
Labels: zaapt, content-type, kiwi-writers
Inserted: 2007-03-10 01:35 (3 years, 4 months ago)
© 2009 chilts.org | Created with LollySite
Privacy Policy | Terms of Use | Original Design: Free CSS Templates.