Reply
How to: Easy way to update all pages
Old 04-17-2008, 10:13 AM How to: Easy way to update all pages
Gilligan's Avatar
Dead Like Me

Posts: 1,608
Name: Stefan
Location: London, UK
This a very common query which is brought up a great deal of the time.

How do I update one file to change my WHOLE website?
or
Whats the easy way to update all my pages with one change?

For example,
You have 50+ pages in your website, and want to add another button to your navigation menu. Instead of going through all 50+ pages and changing your navigation, how would you update one file to update the rest?

Well, it's a simple answer actually.
Server Side Includes (SSI).

Simply creating one file containing your HTML code for the navigation menu, and adding one line to your page, will result in an easy way to update all your files.

There are many ways, such as PHP or ASP.

PHP

for any page you want it to appear
PHP Code:
Your HTML code here

<?php include('navigation.php'); ?>

More HTML here
and inside navigation.php (same directory for this example)
PHP Code:
<div>
Whatever
</div
ASP

ASP has the same concept, but just different coding to do say

for any page you want it to appear
Code:
HTML code here

<!--#include file="navigation.inc"-->

More HTML code here
and navigation.inc would typically contain
Code:
<div>
Whatever
</div>
Getting it to work
For the above two examples to work, the files would need to be saved in either *.asp format or *.php format, either that or you could add a line in your .htaccess file

http://www.javascriptkit.com/howto/htaccess4.shtml

That is a great tutorial for this.
Gilligan is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
     
Old 04-17-2008, 10:36 AM Re: How to: Easy way to update all pages
chrishirst's Avatar
Super Moderator

Posts: 12,808
Location: Blackpool. UK
Sorry, but oversimplified and inaccurate on all but the actual code for the PHP include().

A somewhat more comprehensive walkthrough can be found at
Using includes
with;
SSI
ASP
PHP

</self-promo>
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-20-2008, 10:34 AM Re: How to: Easy way to update all pages
willcode4beer's Avatar
Webmaster Talker

Posts: 695
Name: Paul Davis
Location: San Francisco
I take the reverse approach.
I use templates so, none of the pages know about the decoration.

Originally I did this by implementing a servlet filter to intercept the request, and apply the filter. I've written (and debugged) this so many times in so many places. Now I use Open Symphony's SiteMesh, which is a pretty good implementation.
It can use browser specific templates, useful for legacy systems and pages for phones. It even supports localized templates, so you can use location specific designs. The example always given is, the color red is associated with happiness in most eastern countries, with danger/alert in western ones. It's easily extended too so, you could have a different template for logged-in people vs guests, etc...

The problem with includes (besides exposing information where it's not needed) is, what if you want to change the include, or add another one? You can still be left editing 100+ pages....
Another cool thing with a template filter, is can works with generated pages. I might have a special case servlet (instead of a JSP) that just outputs HTML. A template can handle it. Includes would require code edits and a recompile.
__________________
Paul Davis
willCode4Beer.com (coding for all the right reasons)

Last edited by willcode4beer : 04-20-2008 at 10:39 AM.
willcode4beer is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to: Easy way to update all pages
 

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

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




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12720 seconds with 13 queries