How to put your menu/static info. on every page

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.



Go Back   Webforumz.com > Main Forums > Design Your Website > Starting Out

Notices


Reply
 
LinkBack Thread Tools
  #1 (permalink)  
Old Feb 21st, 2007, 23:24
Junior Member
Join Date: May 2006
Location: UK
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
Question How to put your menu/static info. on every page

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
Reply With Quote

  #2 (permalink)  
Old Feb 22nd, 2007, 00:30
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #3 (permalink)  
Old Feb 22nd, 2007, 01:58
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to put your menu/static info. on every page

menu.html:
Code: Select all
<h1>Navigation</h1>
<ul>
    <li>Home</li>
    <li>Contact</li>
</ul>
your_page.php:
Code: Select all
<html>
    <head>
        <title>page</title>
    </head>
    <body>
        <p>Welcome to our site</p>
<?php
include "menu.html";
?>
        <p>Copyright &copy; 2007</p>
    </body>
</html>
Reply With Quote
  #4 (permalink)  
Old Feb 22nd, 2007, 03:22
Weird1993's Avatar
Moderator
Join Date: Feb 2007
Location: United States
Age: 15
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Weird1993 Send a message via Skype™ to Weird1993
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.
__________________
Daniel Thompson
danielwthompson.com
Reply With Quote
  #5 (permalink)  
Old Feb 22nd, 2007, 03:47
JacobHaug's Avatar
SuperMember

SuperMember
Join Date: Dec 2005
Location: On Internet
Posts: 4,859
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to JacobHaug Send a message via MSN to JacobHaug
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!!
Reply With Quote
  #6 (permalink)  
Old Mar 1st, 2007, 13:52
Junior Member
Join Date: May 2006
Location: UK
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #7 (permalink)  
Old Mar 1st, 2007, 13:59
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to put your menu/static info. on every page

Quote:
Originally Posted by lmc148 View Post
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?
Yes ... just like Ryan posted.

Quote:
Originally Posted by lmc148 View Post
Does this mean you cannot get the pages verified on the WWW Consortium website?
No ... look at the source of you index.php file ... everything is in there. PHP gets parsed by the server so when comes time to view the page everything assembled together and nobody know the difference.

Quote:
Originally Posted by lmc148 View Post
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?
All the page need to have the .php extension yes. No problems at all ... I use that method all the time.
Reply With Quote
  #8 (permalink)  
Old Mar 1st, 2007, 23:01
Junior Member
Join Date: May 2006
Location: UK
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
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?
Reply With Quote
  #9 (permalink)  
Old Mar 1st, 2007, 23:28
SuperMember

SuperMember
Join Date: May 2006
Location: North West, UK
Age: 21
Posts: 1,173
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #10 (permalink)  
Old Mar 2nd, 2007, 01:58
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #11 (permalink)  
Old Mar 2nd, 2007, 01:58
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to put your menu/static info. on every page

Exactly ... it's the same as having

Code: Select all
<html>
    <head>
        <title>page</title>
    </head>
    <body>
        <p>Welcome to our site</p>
<h1>Navigation</h1>
<ul>
    <li>Home</li>
    <li>Contact</li>
</ul>
        <p>Copyright &copy; 2007</p>
    </body>
</html>
That's a XHTML/HTML page ... the only thing you've done differently is remove what's common to all pages (and that's what's in red) and import it when you need it.

The page is still index.php.
Reply With Quote
  #12 (permalink)  
Old Mar 5th, 2007, 11:30
Junior Member
Join Date: May 2006
Location: UK
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #13 (permalink)  
Old Mar 5th, 2007, 12:00
Ryan Fait's Avatar
SuperMember

SuperMember
Join Date: May 2006
Location: Las Vegas
Posts: 3,786
Thanks: 0
Thanked 0 Times in 0 Posts
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.
Reply With Quote
  #14 (permalink)  
Old Mar 5th, 2007, 13:14
Junior Member
Join Date: May 2006
Location: UK
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #15 (permalink)  
Old Mar 5th, 2007, 13:18
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
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

HTML: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-CA" xml:lang="EN-CA">

<head>
    <title>Some title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    
</head>

<body>

</body>
</html>

Last edited by karinne; Mar 5th, 2007 at 13:20.
Reply With Quote
  #16 (permalink)  
Old Mar 8th, 2007, 21:54
Junior Member
Join Date: May 2006
Location: UK
Posts: 38
Thanks: 0
Thanked 0 Times in 0 Posts
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
Reply With Quote
  #17 (permalink)  
Old Jun 28th, 2007, 16:57
Up'n'Coming Member
Join Date: Mar 2006
Location: UK
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to put your menu/static info. on every page

Quote:
Originally Posted by Weird1993 View Post
Or you could just use a template if you for some reason can't or don't want to use PHP.
Too right I don't want to use PHP! Can anyone tell me how to do this with a template in straightforward HTML?
Reply With Quote
  #18 (permalink)  
Old Jun 29th, 2007, 01:59
karinne's Avatar
SuperMember

SuperMember
Join Date: Jan 2007
Location: You know where
Age: 31
Posts: 4,617
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to put your menu/static info. on every page

This article might help

Using includes to add common elements to your sites.
Reply With Quote
  #19 (permalink)  
Old Jun 29th, 2007, 09:53
Up'n'Coming Member
Join Date: Mar 2006
Location: UK
Posts: 94
Thanks: 0
Thanked 0 Times in 0 Posts
Re: How to put your menu/static info. on every page

Hi Karinne,
I found that part quite straightforward, thanks. My problem comes when I want to view my php work locally. I work on a mac which has an Apache server with no php support so I have to upload to my remote server each time I want to test a page.
Installing php support on the mac is something I want to avoid (I'm a bit of technophobe), so just wondering if there's anyother way I can create an updateable template in pure html w/o resorting to Dreamweaver?
Reply With Quote
Reply

Tags
logos, menus

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
info window pop-up on mouse-over of static JPG image aldernon JavaScript Forum 1 May 25th, 2008 22:28
Using wordpress posts in a static page marSoul Scripts and Online Services 11 Jan 25th, 2008 15:42
need to onclick to open info in div on same page apster JavaScript Forum 2 Apr 30th, 2007 09:56
Drop down menu info displayed on same page? Dopeness JavaScript Forum 1 Jan 10th, 2006 07:34
Static menu Jimartist JavaScript Forum 2 Sep 8th, 2005 20:44


All times are GMT. The time now is 22:45.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43