Technote Details :: How to store the menu in a single file
Issue
For a large site, I want to create the menu only once, in a file, and then display the menu on every page of the site.
Reason
This is a good way of reusing code, by placing repetitive items in a file that is called by other pages.
Solution
To accomplish this, take the following steps:
- Create a new page in Dreamweaver and add the CSS menu to it. (e.g. menu.php)
- Switch to code view and manually remove the page directive (from top of the page - the <DOCTYPE > tag), the <html>, <head> and <body> opening and closing tags - leaving only the code that outputs the menu.
- Create the pages for your site. In the place where you want the menu to appear, include the file containing the menu. This is done differently for the various server models:
- For PHP:
<?php include('menu.php');?> - For ASP VBScript:
<!-- #include file="menu.asp" --> - For ColdFusion:
<cfinclude template = 'menu.cfm'>
When you need to edit the CSS menu, you must follow the next steps:
- Open the menu file in Dreamweaver.
- Switch to code view and add the opening and closing <body> </body> tags around the menu code.
- Edit the server behavior for the menu to apply the changes.
- Remove the <body> and </body> tags from the page and save it.