View Full Version : SD-Menu for site-wide use

05-02-2009, 09:13 PM
1) Script Title: SDmenu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/slashdot.htm

3) Describe problem:
I can't figure out how to call upon the menu links contents of the sdmenu script from one location, so that there doesn't have to be a duplicate copy of the script on every page of the site...

I'm not sure if Im wording my question is clear -- But the objective is to have only one source file (like a js file) containing the links of the menu that all pages can use -- so that don't have to edit every page of the site everytime I change the navigation links.

I suspect this may be an ignorant question, but I have searched Dynamic drive and the net trying to find the answer, but still don't know what to do.

Thanks for any assistance. Even a link to a tutorial would be of great help.


05-02-2009, 09:16 PM
If you have PHP enabled on your server, you could use include() (http://se2.php.net/function.include).

Good luck!

05-04-2009, 10:05 PM
If you have PHP enabled on your server, you could use include() (http://se2.php.net/function.include).

Good luck!

Thanks for the reply Snooker.
I will have to learn about php (I know little currently).. Frankly, I'm little more than a copy-n-paste man.

Is my immediately learning php techniques the only method to edit all my navigational menus from one file?
I have this sd-menu spread across a whole slew of pages and there are numerous links needing change.

I guess what I'm asking for is an example to cut and paste.. any chance of that happening?

Thanks again


05-05-2009, 05:30 AM
It's actually not that difficult. Just put all the code you need for the menu into a separate file, can even be a txt file:

<div style="float: left" id="my_menu" class="sdmenu">
<span>Online Tools</span>
<a href="http://tools.dynamicdrive.com/imageoptimizer/">Image Optimizer</a>
<a href="http://tools.dynamicdrive.com/favicon/">FavIcon Generator</a>
<a href="http://www.dynamicdrive.com/emailriddler/">Email Riddler</a>
<a href="http://tools.dynamicdrive.com/password/">htaccess Password</a>
<a href="http://tools.dynamicdrive.com/gradient/">Gradient Image</a>
<a href="http://tools.dynamicdrive.com/button/">Button Maker</a>
<span>Support Us</span>
<a href="http://www.dynamicdrive.com/recommendit/">Recommend Us</a>
<a href="http://www.dynamicdrive.com/link.htm">Link to Us</a>
<a href="http://www.dynamicdrive.com/resources/">Web Resources</a>
<div class="collapsed">
<a href="http://www.javascriptkit.com">JavaScript Kit</a>
<a href="http://www.cssdrive.com">CSS Drive</a>
<a href="http://www.codingforums.com">CodingForums</a>
<a href="http://www.dynamicdrive.com/style/">CSS Examples</a>
<span>Test Current</span>
<a href="?foo=bar">Current or not</a>
<a href="./">Current or not</a>
<a href="index.html">Current or not</a>
<a href="index.html?query">Current or not</a>

and save it as menu.txt for instance.

Then all you need to do is add this code on the pages where you want the menu to appear:

<?php include'menu.txt'; ?>
You also have to change the extension of all pages to .php if you don't have that already.

Good luck!

05-05-2009, 01:23 PM
If you cannot use PHP, you could use this (http://www.dynamicdrive.com/forums/blog.php?b=26). There's a link to demos on the page.