Log in

View Full Version : How to modularize CSS menus



WyrdForge
10-16-2008, 04:20 AM
Here's a noob question to be sure: how do I modularize CSS menus? In other words, I want to define a menu (e.g., SuckerTree Horizontal Menu) once, and then call/invoke it from any number of pages. Is this possible, or must I duplicate the HTML code in every page? Seems to me that last method would be inefficient, since a change to the menu would require a change to each and every page. All suggestions gratefully accepted, WyrdForge.

Moshambi
10-16-2008, 02:18 PM
The only way I could think to do this would be to create your menu in a .htm/.html file, then wherever you want it to be just use PHP to include it:




<?php include("menu.htm"); ?>



That will insert it into any page you have the include in and whenever you need to modify the menu you will only have to edit the one file.

Hope this helped.

WyrdForge
10-16-2008, 04:17 PM
Thanks for your reply. I should have also mentioned that the web site I'm redesigning is hosted on a zero-cost basis, and therefore provides absolutely no server-side services. I'm limited to client-side includes, JavaScript, and others I can only guess at.

Moshambi
10-16-2008, 04:40 PM
Oh I see. I'm not sure if there is a way for you do it then. Unless maybe you make a JavaScript Menu or some kind of Dynamic DHTML Menu or something... that might work. Not to sure though :(