Dynamic Generation of Menu Structures and JavaScript Rollovers in PHP - Adding Pages (
Page 6 of 6 )
Now that the TEMPLATE.HTML file is
completed (with the possible exception of changing the table border to 0), it
can be used as the basis for new pages on the web site. Just do a SAVE AS to the
filename of the new page, and put the page content in the "3 - Main Body"
area.
Don't forget to go into PAGES.HTML and add the name of the new page
to the array definition. By the way, the pages named in the array display in the
menu in the exact order in which they occur in the array. By altering this
order, you can alter the order in which pages appear in the menus.
You
will also need the following 5 graphics files for each page:
- FOO-H.gif - header graphic
- FOO-B.gif - graphic panel that changes when hovering over buttons
- FOO-OFF.gif - default button displayed for non-current page
- FOO-ON.gif - button displayed when onMouseOver
- FOO-IN.gif - button graphic displayed when page is current
(GIF files were used in this example. JPG's and PNG's work just as
well. Just remember that every file of each type must be the same
format.)
Adding one page or one hundred pages is now just a matter of
using the template file and then generating the graphics files.
Using PHP
for the dynamic generation of menu structures and JavaScript can dramatically
cut the time it takes to develop a site, and certainly makes site maintenance a
breeze compared to having to edit each page when other pages are added or
removed. Adding or deleting pages from the site's menu structure is now just a
matter of making minor changes to a few files, and producing some
graphics.
Another good use for PHP is separating the content of a page
from the structure of a page, thus making site maintenance even easier and
nearly eliminating formatting mistakes, but that's a subject for another
article.