These drop-down menus are a useful way to display the various options available on a web site. There are a number of different ways to get this effect. My version here used only html and CSS but I decided that it was worth couching the menu in the context of php. While it can also be prepared with other scripting languages (javascript or asp), php is a natural environment for IAGenWeb because of the type of computer/OS that serves up these pages. It is not that difficult to do. Here is roughly what I did.
First off, this approach really only makes sense if one already organizes his/her site with about 5-10 top-level folders, each possibly containing subfolders. For me, the top-level folders correspond to each of the main menu items (read them across), while the submenu items indicate the subfolders within each folder. To have the menu uniformly on each page (except perhaps the first page), one needs to view each page consisting of three main chunks: top matter, content, bottom matter. Most of the content that is viewed is in the content section. For me, the top matter consists of a banner (very top part of each page), the menu, and the bread crumbs (navigation tool). For me, the bottom matter is just a footer consisting of a link to the top, my email, some basic comments and the disclaimer. I have all the bottom matter written a simple file, called Bottom.html, that consists of just this information just described. The key is that this is written once, stored in ONE file, and then read into to each page that is to be displayed. For me, I used the following code that is given as the last code before the closing body tag:
<?php include "/home/iagenweb/public_html/marion/SiteWideFiles/Bottom.html" ?>
. Similarly, the first line of code after the opening body tag is the following: <?php include "/home/iagenweb/public_html/marion/SiteWideFiles/Banner.html" ?>
, which reads in the top banner portion. After this, I have the line <?php include "../SiteWideFiles/Menu.php" ?>
that reads in the file that defines the menu and the breadcrumbs. The astute reader may notice that the first two includes used absolute links while the latter used a relative link. The latter approach is more of a pain to maintain since one needs to always keep track of how "deep" one is but it is slightly faster. I probably should have been consistent and done all three the same way. Finally, following this I might have a line like <?php writeMenu('Community') ?>
, which instructs the menu and bread crumbs to be written out and the particular menu highlighted. Things don't need to be this fancy, but this gives the reader of an overview of what needs to be done FOR EACH file. One last thing: each file needs to have its extension changed to .php instead of .html or .htm. This is needed so that the web server knows to pay attention to these php include statements. Otherwise, there is really not more that needs to be done.
If the reader is interested to learn, I am happy to share my code. Keep in mind that this also can be done in stages, which is how I converted this site. I decide how I wanted the site organized (main folders/menus) and then I built the menu to accomodate this. After this, I simply changed files or folders as I had time and added them into the new structure. Your old structure can have its links point to the new structure and you can gradually convert over. Consider it.