Question

How to: Change text/menu in one place to have it appear (with h-links) on all the other pages

Asked by: rightmirem

Hey Gang,

Not really a web designer...really a UNIX admin with a web design need.  I am creating a web site containing data about servers.  As servers get added, the main menu has to change to include the new server WITH its link to that server’s data page.  The main menu needs to appear on every page.

Currently, I update the HTML for the menu on the index page, and then just cut-and-paste the new menu to the top of ALL the other pages.  This is getting to be a nightmare.  Is there a way to dynamically link the text to all the other pages, such that I can change the text AND the hyperlinks in ONE location and have the new data appear in the right spot on all the other pages (without having to manually change them.)

I would LIKE to avoid using frames to do this.  Flash is not ENTIRELY out of the question, but it would be best if I could do this with HTML/DHTML/XML/JSP or something equally simple to serve up (pages will be served by Solaris and apache.)

Thanks!
Mike

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2004-07-08 at 15:01:50ID21052630
Tags

change

Topic

Miscellaneous Web Development

Participating Experts
8
Points
500
Comments
14

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. DHTML menus
    Does anyone have the code for the dhtml menus used on microsoft.com?
  2. Free DHTML menu request
    Hi gals and guys, I'm really newbie in DHTML (starting from scratch right now) but I used to use PHP, HTML. I'm looking for a "free" DHTML menu "easily" customizable. I don't need a menu which can be updated dynamically. If I have to update the source fi...
  3. Looking for a DHTML Menu script
    Need a DHTML Menu script that'll let me put in my links, and it takes care of all the grunt work. But I need one that will take the screen size into account. There were be several levels (maybe five deep) and with the one I have now, it keeps going to the left. I need it t...
  4. DHTML Menu (Cross-Browser)
    I need a DHTML horizontal hierarchical menu. - It must be cross-browser. (NS4+ IE4+) - It must use an unordered list or simple XML as it's data source. Thanks.
  5. What is DHTML
    1 What is DHTML, dynamicHTML? 2 Is it a whole new language with its own syntax? 3 Is there much to it if you know HTML and ASP?
  6. DHTML/javascript menu works from IIS 6 but not Apache…
    This is a fairly urgent - and maybe difficult - problem: We have a website with a javascript menu that, when the site is hosted on an IIS server, works well in all browsers we tested. When we moved the site from the IIS development box to our existing Apache 2.0.52 on RedHa...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: ZylochPosted on 2004-07-08 at 15:23:20ID: 11507413

Yes, it is possible with server-side scripting languages like JSP, but you would also need a database or a text file.
I'm pretty clueless at JSP, so I'll give you a small example in PHP:

Depending on whether you use a textfile or a database, you would need to manually add the server unless you create something to do it for you. For that reason, it's best if your site isn't heavily used to use a textfile (very easy), but if you have a large volume of people, you should use a database (for PHP, best is with MySQL);

For an example with a textfile, it might be something like this:

<?php
//For the text files, put a different server on each line.
$menufile="files/server.txt";                         //This path is an example one.

//Open with PHP
$fp = fopen($menufile, "r");

//Get the server names and close the file.
$contents = fread($fp, filesize($menufile));
fclose($fp);

//Now $contents has what's in the file, so split up the files into an array by the newlines.
$arrayOfServers = explode("\r\n", $contents);             //If this is stored on Unix server, use the \r\n, otherwise use \n.
?>
<!-- Skip a bit until you get to your menu part, this could be something simple like this:

<body>
<div>
<?php
for ($i=0;$i<count($arrayOfServers);$i++) {
echo("<a href='SOME LINK'>" + $arrayOfServers[$i] + "</a><br>");
}
?>
</div>
</body>

I know that the above menu is simplified, and that it doesn't have the server links, but it can easily done if you either
1) Make another file with the server links (make sure the links are on the same line as the name is, i.e. if ServerName is on line 1 in server.txt, then ServerNameLink has to be on line 1 in serverlink.txt then you can use the for loop above because the $i will refer to both arrays.

2) In server.txt, have it in this format:
ServerName1,ServerLink1
ServerName2,ServerLink2
ServerName3,ServerLink3

Then have PHP explode() the according to "\r\n" then explode each of the members of the resulting array using a for() loop by the commas to get an array of server links (for the href) and an array of servernames (for the link names)

Of course, this is assuming you are using PHP, if you are using another server-side scripting language, either learn about filehandling in it or ask the experts in that particular section.

 

by: ZylochPosted on 2004-07-08 at 15:24:42ID: 11507425

Forgot to mention something:

With PHP, if you want to include the page at the top of each HTML page, instead of using the code in all of the pages, just put htis in all of the pages:

<?php
include_once("header.php");                     //Assuming the name of the menupage is header.php
?>

--Zyloch

 

by: ploubierPosted on 2004-07-08 at 15:27:21ID: 11507464

 

by: COBOLdinosaurPosted on 2004-07-08 at 15:42:33ID: 11507583

The common and easy solution is to use a server side include.  A single file with the menu code that gets included in every page.  You cahnge it in one place and it automatically gets picked up by every page.

All it requires is that the server be configured to support includes.  Information here:

http://bignosebird.com/ssi.shtml

Cd&

 

by: websethPosted on 2004-07-08 at 17:16:13ID: 11508044

To do this as simple as possible......you have to use PHP, JSP, ASP.NET, or some other type of web programming language. HTML alone will not be able to dynamically do this. You will need to choose one, and go from there.

From there, you can do one of two things.
1.) Have menu.php(or whatever extension) and do the actual work there. Use that language's include syntax, and include it in every page that needs the menu. Then you update menu.php, and it automatically updates all pages with the include.

2.) Dynamically link menu.php to textfile or database, and you update the database or text file, which updates menu.php, which updates all of the other files. (Before we could get into specifics, you would have to choose a language.)

--Seth

 

by: VincentPugliaPosted on 2004-07-08 at 17:29:19ID: 11508090

Hi,

  the solution actually depends upon what you mean by 'menu' and what yours looks like.  However, you could include the data within each page with a *.js page.

<html>
<head>
<script type='text/javascript' language='javascript' src='somepathAndname.js'>
</script>
.......
</html>

The *.js file should contain your menu items with the following caveats:
1) there should be no html in the file; this includes <script...>
2) if you need to include data, do so:
    var menuItems = new Array("http://path/filename.ext", ......);
3) if you absolutely must have html, docWrite it:
   document.write("<a href = '" + menuItem[0] + "'>some Server<\a>")

  If you supply an example of your menu....

Vinny

 

by: a1programmerPosted on 2004-07-08 at 17:54:00ID: 11508162

Hi,

Looks like you have plenty of suggestions, but I'll throw in my 2 cents anyway.

It all depends on how automated you want it, and how simple you want to keep it.

If you aren't going to be changing the list that much, I would consider VincentPugalia's solution (Date: 07/08/2004 07:29PM CDT).  

I would modify it a bit, just to make it even simpler.

//-- file include.js
function displayServerList(){
var serverList = '';

serverList += '<a href="addresstoserver1">Server 1</a>';
serverList += '<a href="addresstoserver2">Server 2</a>';
serverList += '<a href="addresstoserver3">Server 3</a>';

    document.write(serverList);
}


Then in head your html page.
<script language="javascript" src="include.js"></script>

Then wherever you want it displayed within the page.

<script language="javascript">
     displayServerList()
</script>


However, if this list is going to update very frequently, I would investigate the very first comment.  Use a mysql database with php.


__
A1

 

by: pkaledaPosted on 2004-07-08 at 19:33:11ID: 11508496

VERY SIMPLE.  There are many ways.

If you can run ASP pages, you can simply include another file.  You would create a file with your navigation and call it navigation.html.   then on the ASP page you could just add this code <!-- #include file="Navigation.html" --> .  This would simply include it as the page is being created.  

A very similar way in PHP files is to use the same Navigation.html page with this code in your target document:
<? include("Navigation.html") ?>

Using Javascript that you can run on any page server.  Create a file called Navigation.js and in that file you build it like this:
Document.write('<a href="target">link1</a>');
then on your page where you want to include the navigation you would just put this code:
<script language="JavaScript" src="copyright.js"></script>

PK

 

by: kernelkonfusionPosted on 2004-07-11 at 09:32:00ID: 11523742

You don't even need ASP, PHP or Javascript and maybe all these are needless complexities on a basic Solaris machine running Apache as this combination natively supports Server Side Includes, just turn it on this feature and use it as documented in Apache documentation.  Basically, you need to enable this using the options
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml

where .shtml is the file name extension of the files you want the server to parse.

Then you have to make sure that the directories where these files will be found have a .htaccess configuration file with the directive:
 Options +Includes

There is a tutorial at:
http://httpd.apache.org/docs-2.1/howto/ssi.html
There, they describe an example for including a standard footer as well as many other neat tricks you can do with this feature.

 

by: pkaledaPosted on 2004-07-11 at 10:24:47ID: 11523961

KernelKonFusion:

The same is true in IIS.  You can just save your file as file.shtml and include other html files within it using this code:  <!-- #include file="Navigation.html" -->  That way you do not have an asp page running.

 

by: kernelkonfusionPosted on 2004-07-11 at 11:06:50ID: 11524147

Indeed, but I don't believe IIS runs on Solaris.

 

by: rightmiremPosted on 2004-07-12 at 10:54:39ID: 11531666

All good suggestions...and, actually, the shtml option would probably have been a better option from the standpoint of making the shtml file to include.  

I ended up already implementing the solution with JavaScript, and it works beautifully.  The only drawback, as alluded to previously, was the fact that creating the initial include file with the menu and the links was a pain, as you just have to type it out in VI, with all the formatting added manually.  I suspect a shtml include file would have been easier to initially implement, but now adding new servers and such will be fairly easy.

Thanks again!
Mike

 

by: a1programmerPosted on 2004-07-12 at 10:56:14ID: 11531681

Cool...

Glad you got it working.

 

by: pkaledaPosted on 2004-07-12 at 11:32:16ID: 11532014

Glad we all could help.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...