Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

Coding Forum


You are currently viewing our Coding Forum as a guest. Please register to participate.
Login



Reply
How to: Easy way to update all pages
Old 04-17-2008, 11:13 AM How to: Easy way to update all pages
Gilligan's Avatar
Website Designer

Posts: 1,670
Name: Stefan
Location: London, UK
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE
Gilligan is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-17-2008, 11:36 AM Re: How to: Easy way to update all pages
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-20-2008, 11:34 AM Re: How to: Easy way to update all pages
willcode4beer's Avatar
Super Moderator

Posts: 1,533
Name: Paul Davis
Location: San Francisco
Trades: 1
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.
__________________

Please login or register to view this content. Registration is FREE


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

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 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.28877 seconds with 12 queries