February 7, 2011

Automatic menu generation for my web site

by dwm — Categories: Software Development, Web Development — Tags: , , , , , 1 Comment

It’s tedious to need to update the menu on each of my web pages when I add new children of a page, new siblings of a page, or move a page or directory. Especially since I keep my content organized via the underlying filesystem; why should I have to do more than that to get a menu that shows child directories, siblings and ancestors? I shouldn’t. One could argue that the easiest way to achieve what I want is to not have any index files, but that’d be quite ugly.

I’ve instead written a CGI program in C++ that will automatically add a ‘Genealogy’ menu to a page’s side menu. Within the ‘Genealogy’ menu are submenus: ‘Children’, ‘Siblings’ and ‘Ancestors’. I call the CGI from the RenderHeader() member of my PageStart PHP class to add to the side menu. Simple, always works. The only downside is that it’s a little slow since it accesses the Xapian backend to get page titles to use in the menu. I can live with it for now. I may later write the menus to files in batch mode and remove the CGI.

1 Comment »

  1. dwm says:

    My CGI program can now also generate a main menu (static) as well as a simple line of ancestry links (used at the top of each of my pages).

Leave a Reply

© 2020 rfdm blog
All rights reserved