Log in

View Full Version : Help with Navigation Menu



walazins
06-23-2008, 08:42 PM
I run a CSS based site with 2 columns and a header. It is a fitness site that contains about 40 pages, and we will be adding new atricles and will bring it up to nearly 300 pages. I am trying to establish my navigation menu so that If I were to have a change of the menu sometime in the future, that I could edit it from one spot, and not have to modify it on 300 different pages for this to take affect.

I have been unable to locate any help documents on this tpoice, so if anyone knows of any, or can steer me in the right direction, Id appreciate it.

Thanks

rangana
06-24-2008, 12:31 AM
Do your server (by chance) allow server-side (PHP)?
If so, then you might find PHP include() (http://us3.php.net/include/) useful.

JasonDFR
06-28-2008, 08:40 AM
This assumes your web server has php installed.

Put your main navigation into a text file. Name it main_nav.php . There should not be anything else in this file. For example:




<div class="clearfix" id="nav">
<ul>
<li id="t-home"><a href="/index.php">Home</a></li>
<li id="t-practice"><a href="/practice_areas.php">Practice Areas</a></li>
<li id="t-about"><a href="/about.php">About</a></li>
<li id="t-fees"><a href="/legal_fees.php">Legal Fees</a></li>
<li id="t-contact"><a href="/contact.php">Contact</a></li>
<!-- <li id="t-blog"><a href="/blog/">Blog</a></li> -->
</ul>
</div> <!-- end nav -->



Then in the HTML for each page, put this where ever you want the main nav to appear:



<?php

include ("main_nav.php");

?>


Save you html files as "filename.php" .

Now whenever you change your main_nav.php file, the changes will display on every page where you have included the above php code.

You can expand this idea to the header and footer as well. So if your header or footer ever changes, you'll only have to make changes in one place.

If anyone is reading this that has not mastered this technique, you owe it to yourself to learn how to do it.

Good luck,

Jason

laserfloyd
07-01-2008, 12:33 PM
Yes, use a PHP include. It will make life easier! :) And like Jason said, you can expand it to the footer as well. Or expand to anything that will be repeated on several/all pages. No point in having to edit dozens of pages when you can update one file.