HomePHP Page 5 - Dynamic Generation of Menu Structures and JavaScript Rollovers in PHP
Ordering up a Menu - PHP
Did you ever have one of those sites that started out small, but kept growing and growing? Adding new pages to a site or removing old ones can often take more time than developing the pages themselves.
Now that the JavaScript is properly generated, the page needs a complimentary menu structure for the links to other pages. Let's dive right into the code, replacing the "2 - Menu Area" text with:
It sure does look complicated, but it's pretty much the
same HTML anchor tag we put in the TEMPLATE.HTML file above, but parsed to see if the array element is the current page, and with a whole bunch of escape characters and PHP variables.
This code uses the $COUNTER variable defined earlier in the script in another DO loop, and generates the appropriate HTML code with JavaScript support. Line 7 introduces another graphic file, FOO-IN.HTML, which is the "third" button file, the other two being FOO-ON.HTML and FOO-OFF.HTML referenced already in the JavaScript.
The only part left to do is add the HTML line referencing the graphic panel that changes when hovering over the buttons:
This file can actually be put anywhere in the page, but
for the sake of simplicity I put it in the menu structure for this example. Since it is referenced by the "NAME" attribute, this is all that is needed to use this graphic in the onMouseOver effects. JavaScript takes care of the rest.