This is a discussion on "How to put your menu/static info. on every page" within the Starting Out section. This forum, and the thread "How to put your menu/static info. on every page are both part of the Design Your Website category.
|
|
|
|
|
![]() |
||
How to put your menu/static info. on every page
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
#1
|
|||
|
|||
|
Hi
I'm still hand coding all my menus/static info. (e.g. logo) onto every page as it's the only way I know how to do it, but if I want to add one thing to the menus then I have to change 20 pages! There must be a better way to do this. Please help. Thanks L |
|
|
|
#2
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Yes ... there is a better way and they are called includes. If your server supports PHP, I suggest you use that. Here the info for the include() function in PHP. You really don't need to know anything about php to use it and it's easy as pie.
|
|
#3
|
||||
|
||||
|
Re: How to put your menu/static info. on every page
menu.html:
|
|
#4
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Or you could just use a template if you for some reason can't or don't want to use PHP.
|
|
#5
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
But the included is the best and easiest way to accomplish this effect...Almost every one of my websites use the included feature...it is GREAT!!
|
|
#6
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Thanks for all your info. guys.
Ryan - I've been playing around & I've got my index page to work following your model. I set up 2 pages - menu.html & index1.php, but to get it to work I had to strip out all the xthml guff that you nomally have to start the page with out of both pages i.e. the .html page & the .php page. Is this right? Does this mean you cannot get the pages verified on the WWW Consortium website? Also, does it mean that all the pages (other than menu.html) for the website would become .php pages rather than .html pages? Does this pose any potential problems at all? Hope you don't mind me asking as I don't fully understand the implications & I don't want to change all my pages then hit a potential problem! Thanks a lot Lynn |
|
#7
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Quote:
Quote:
All the page need to have the .php extension yes. No problems at all ... I use that method all the time. |
|
#8
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Thanks Karinne.
I understand that using php/include looks seamless to the user & I've got a page working & checked it out for myself - it's great! I can see how it's so much better & easier to code this way & will save me loads of time (once I've gone through & converted all my pages that is :-O ) Just one thing though, I don't understand your reply to "Does this mean you cannot get the pages verified on the WWW Consortium website?" When I did my xhtml course our tutor said we should make sure our code was good i.e. compliant with the WWW Consortium guidelines (& then we could put the following symbol on compliant pages if we wish): ![]() I've also seen quite a lot on this forum about adhering to standards & bad coding etc. & members on here agreeing webdesigners should conform to the standards. I thought that if you don't start your page with the correct opening 'xhtml guff' (sorry, can't remember technical term!) then it will not adhere to the WWW Consortium standards? |
|
#9
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
But you have started with the correct doctype. That 'menu.html' is not a standalone page it is just a piece of html that is going to be inserted into a properly declared xhtml document. As long as your index.php has the correct doctype (and you have played by the rules) your page will still validate.
Pete. |
|
#10
|
||||
|
||||
|
Re: How to put your menu/static info. on every page
index.php should have all the XHTML declarations, an html, head and body tags, etc. Everything to make a site validate. menu.html will not have this because it's only part of the full document. It should still be valid XHTML, but it will not validate on its own. Only index.php should validate. Does that answer your question? Your question is a little hazy.
|
|
#11
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Exactly ... it's the same as having
The page is still index.php. |
|
#12
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Sorry my question is a little hazy.
When I did my xhtml course our tutor said we had to put something like this at the top of the page to get W3C validation: <?xml version="1.0" encoding="ISO-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//xhtml1/DTD XHTML 1.0 Transitional//EN" "http://WWW.W3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> What you're saying is that ALL of this can be replaced with just: <html> so that's why I was a little alarmed & wondered if the page would still W3C validate? If it does then I'm happy with that but wonder why our tutor made us put all that stuff at the top of every page if it isn't necessary? Any idea? One final thing, because the pages have the .php extension I don't think I can look at the page in a browser on my PC. I have to upload it to my host to look at it? Is there any clever way of testing the page or is the only way to upload it to the host? Hope I'm not being too much of a pain asking these questions, I just want to make sure I really understand what I'm doing before making these changes. Thanks Lynn |
|
#13
|
||||
|
||||
|
Re: How to put your menu/static info. on every page
NEVER use <?xml version.... > as the first line of your code. Use only the <!DOCTYPE>. The ?xml tag is not required, and more importantly, it will throw IE into quirks mode which will in all likelihood cause problems.
Karinne was just shortening the document structure in her example. You'll want to include the doctype in the page. Karinne and I understand HTML more than you do, so forgive us for using shorthand when describing things The reason why .php pages aren't showing up on your own computer is because PHP isn't installed on it. Install PHP and the pages will show up as they should. |
|
#14
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Do you have an example page that I can look at just to see what code you have at the top of it before the <html> ? Not sure what I should be using now.
Thanks Lynn |
|
#15
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Just the doctype - Recommended DTDs to use in your Web document.
See the template? ... just don't put the <?xml version="1.0" encoding="utf-8"?> line
Last edited by karinne; Mar 5th, 2007 at 13:20. |
|
#16
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Hi
Just wanted to say a big thanks!!! I have changed all my pages on my website & I'm really pleased with the results! L |
|
#17
|
|||
|
|||
|
Re: How to put your menu/static info. on every page
Too right I don't want to use PHP! Can anyone tell me how to do this with a template in straightforward HTML?
|
|
#18
|
|
|