3 Replies - 1384 Views - Last Post: 22 June 2009 - 04:23 PM

#1 crazyjugglerdrummer   User is offline

  • GAME OVER. NERD WINS.
  • member icon

Reputation: 124
  • View blog
  • Posts: 690
  • Joined: 07-January 09

change header of site, can I change one place to change all pages?

Posted 22 June 2009 - 01:42 PM

I don't actually have a site up, but on most sites there's usually a header and a nav bar that's the same on all the pages. If I want to make a change to either one, is there a way to just make the change in one place and see it reflected on all the pages? The html code would have to get the header and nav code from one location, as opposed to you just pasting the code into all the pages. I suppose you could use a server side language to read the html from a file and write it into all the pages on the site, so you'd only have to change the file. You could use frames too.

I'm really hoping this is possible, because it would make it so much easier, instead of going to every page on the site and editing the html. Browser caching could also help page load time, since its the same thing repeated on all pages.

thanks guys! :)

Is This A Good Question/Topic? 0
  • +

Replies To: change header of site, can I change one place to change all pages?

#2 William_Wilson   User is offline

  • lost in compilation
  • member icon

Reputation: 207
  • View blog
  • Posts: 4,812
  • Joined: 23-December 05

Re: change header of site, can I change one place to change all pages?

Posted 22 June 2009 - 01:47 PM

With pure html, you would probably have to use frames to accomplish this. You would be better off using a server side language such as PHP. This would allow you to create a file or function (whichever you prefer) to be imported or called wherever the header is required.
Was This Post Helpful? 0
  • +
  • -

#3 gregwhitworth   User is offline

  • Tired.
  • member icon

Reputation: 221
  • View blog
  • Posts: 1,613
  • Joined: 20-January 09

Re: change header of site, can I change one place to change all pages?

Posted 22 June 2009 - 04:15 PM

Use server side includes - doesn't need special language - most hosting servers support it.

http://en.wikipedia....r_Side_Includes

EX:

<!--#include virtual="header.html"-->



--

Greg
Was This Post Helpful? 0
  • +
  • -

#4 Ryanmiller   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 21-June 09

Re: change header of site, can I change one place to change all pages?

Posted 22 June 2009 - 04:23 PM

Yes, most commonly with the use of PHP includes which all major hosting companies support.


Just make the file: header.php, footer.php, etc and in those files, make the actual headers and menu bars, etc.

And then on each page, insert this code

<?php include("header.php"); ?>

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1