Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

This is probably a duplicate, but I can't find the answer anywhere (maybe I'm searching for the wrong thing?) and so I'm going to go ahead and ask.

What is the accepted standard practice for creating a menu that is stored in a single file, but is included on every page across a site? Back in the day, one used frames, but this seems to be taboo now. I can get things layed out just the way I want, but copy/pasting across every page is a pain.

I have seen php-based solutions, but my cheap-o free hosting doesn't support php (which is admittedly a pain, but it's a fairly simple webpage...).

Any ideas for doing this that does not require server-side scripting?

share|improve this question
add comment

5 Answers

up vote 2 down vote accepted

If your web hosting supports server side include files, you could store the menu in a separate html file with just the code (no html, header, body, etc. tags). On the page(s) you want to reference the menu, to call the code you'd use an SSI, a reference that would look something like this: <!--#include virtual="http://www.yoursite.com/includes/menu.html" -->.

Hope that helps.

share|improve this answer
add comment

You could run a script to complete your pages prior to uploading to the server. After all, what stops you from running PHP locally and then uploading the results?

share|improve this answer
    
I've considered this, but due to this craptastic server, it's a pain to upload files (no ssh) and so I typically just edit online. I may have to just break down and write a quick upload script, which I've been meaning to do anyway. –  TJ Ellis Dec 28 '10 at 18:55
    
@TJ Ellis: Is there no SFTP? And how do you intend to write an upload script (I thought there was no server-side scripting)? –  Lèse majesté Dec 29 '10 at 0:25
    
Uploading over S/FTP is pretty standard. SSH tends to be a premium feature since it's a security issue unless properly setup and/or you have dedicated hosting. –  Nerdling Dec 30 '10 at 12:08
add comment

Tough question, but we still have some workarounds to try on:

Server-side includes (SSI)

If you server allows that, you can use @SubTypical solution

XML + XSLT

Yes, none so far told about this one. Will not extend the conversation:

http://www.google.com/search?q=including+files+with+xml+and+xslt

It can be a little pain, but worth while.

share|improve this answer
    
XSL is a good approach; hadn't thought of that one. –  Lèse majesté Dec 29 '10 at 0:23
add comment

I hate to even mention this, but it would probably work... you COULD do it in javascript as a bunch of document.write statements and then the script could be mainatained separately from where it's called.

I'd move to a host with PHP though before i messed with that. I'm with hostmonster.com. They offer multiple domains, PHP, MySQL a lot of add ons and it's like $5/month.

Good luck.

share|improve this answer
add comment

You could create a separate page then use an ajax JavaScript request to retrieve and fill out the menu. This really should probably be on stack overflow.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.