2

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?

5 Answers 5

2

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.

1

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?

3
  • 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.
    – Tara
    Commented Dec 28, 2010 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)? Commented Dec 29, 2010 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.
    – Jeremy L
    Commented Dec 30, 2010 at 12:08
1

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.

1
  • XSL is a good approach; hadn't thought of that one. Commented Dec 29, 2010 at 0:23
0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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