Click to See Complete Forum and Search --> : How to add menu to every page


Alison556
07-11-2009, 05:51 PM
I don't know if I have this in the right place and didn't even know what to call the topic!!

I'm updating my website and have my CSS all sorted and my javascript and also the HTML elements for the menu links.

What I'd like to know is is there a way of doing it that I don't need to add the script to the top of every webpage? Ideally, I'd like to have just one page of script so that if I had to edit it, I wouldn't have to go through every single page of the website.

I hope I've explained that properly. Any advice and idiot-proof instructions would be most gratefully received.

Thanks

Alison

6StringGeek
07-11-2009, 10:19 PM
http://www.w3schools.com/PHP/php_includes.asp

LiteTest
07-12-2009, 07:02 PM
If you are using any server side programming language you can do this in the language of your choice. If you are using Php, you can follow 6StringGeek's link and that will show you how.

If you are using .Net you can use a MasterPage, etc.
Just google "include" followed by your preffered language.

Now, if you don't make use of serverside programming, and are stuck using normal html pages, there is still hope.

You can use dreamweaver, which allows you to create templates for just this scenario.

If you are using any other html editor, just look through the help of your program and see if there are any references to templates (or includes).
If you can't find any, perhaps it's time to get a new editor.

Alison556
07-12-2009, 07:17 PM
Thanks. I had a bit of a go with 6StringGeek's link but I couldn't get it to work - but I've not had a lot of time to tinker. I did find a site that shows you how to do it in HTML but I've not had a chance to try it. Is that not a good way to go?

I'm using mainly Notepad for editing HTML but I've got an old version of Frontpage. I don't really use that for editing - mainly just for viewing pages and setting out photographs. I had loads of problems getting pages to validate when I used purely Frontpage.

Fingers crossed and I'll have a proper go at it.

This is where I'm maybe asking a silly question - but do I have to upload the files to the server before they work? I really am a novice at this and learning as I go

aj_nsc
07-12-2009, 07:23 PM
If you don't have a server on your local machine, then for the PHP include method you need to upload your pages to a PHP enabled server. Also make sure that your pages end in .php OR, if your files end in .html that .html files get parsed by the PHP parser....(easiest way is to just name the extension .php).

LiteTest
07-12-2009, 07:35 PM
I don't think 6StringGeek will work for you unless the server where you host your pages have PHP, and if they do, you need to rename your .html files to .php

You need to run a web server on your local computer if you want to be able to try out anything using serverside code (if you just click on your html documents and view them directly in your browser, you don't make use of a webserver).

If your live host (where your url is pointing to) supports server side includes in any way you could make use of that but it would be quite hard for you to see the results since you would actually have to upload your pages every time you wanted to see the change.

Regarding your editors, I think Frontpage is a pretty bad product. The best one I know for writing html is dreamweaver. You can get a free trial of that from adobe.com and you don'can view the pages locally (on your own computer) before you upload them.

Last but not least, there are ways you can do normal file includes in html but that is also depending on the server you use for your website, and you would not be able to see these on your local host (that's your computer that you are using to write the html).

If you have the time then I would recommend going into serverside programming.
You don't have to go very deep to start learning about these things, and it opens up new doors to what you can do with your website, how you can interact with your users etc.

If you don't have time or interest in programming (it does take a certain kind of person for that) then my best advice would be to use a better Html editor that supports templates.
Dreamweaver is quite expensive to purchase but I'm sure there are cheaper (or even free?) edtitors with wysiwyg support.

Oh an idea just popped into mind, something that will beat boring old Notepad, is Notepad++
It's free (and I think it even support code high-lighting for html).

You could probably do a clever find-and-replace in all files where your menu is (just stick a marker comment in your html as such <!-- menu goes here --> and you can just find that in every page and swiftly replace the menu.

Alison556
07-13-2009, 12:11 PM
Brilliant - thanks for all the replies - that's explained things for me better now.

I'll need to ask my hosts if they support php.

I do actually have a copy of Dreamweaver but because I was so used to FrontPage at the time, it kinda freaked me out (mainly because I didn't understand it all!) but I've since realised that FrontPage isn't great to make a site up from - so I started doing all my pages in notepad and only using FP for adding pics or just viewing the page without having to upload it.

I am interested in programming but have to rely on here and just scouring the net for help and information and sometimes it just gets a bit confusing. I've surprised myself that I've managed to go from a purely FrontPage generated page to being able to code it in HTML, do a CSS sheet (though I had to get the code from the internet that was a little bit like what I wanted then through trial and error tweak it to what I wanted it to do - though I'm sure it could be a whole lot better).

I've downloaded Notepad++ so I'll have a tinker with that tonight and I might even re-install Dreamweaver and see if I can get to grips with it now. I know a bit more now than I did when I first tried it so maybe it'll make more sense now.