![]() |
|
|
How to: Easy way to update all pages |
|
DEAD Good Coder
Posts: 1,095
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:
PHP Code:
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 Code:
<div> Whatever </div> 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.
__________________
Offering Website Design Worldwide, please visit my website |
|
|
|
| Sponsored Links (We share ad revenue): |
|
|
Re: How to: Easy way to update all pages |
|
Super Moderator
![]() Posts: 10,609
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 |
|
|
|
|
|
Re: How to: Easy way to update all pages |
|
Webmaster Talker
Posts: 525
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. Last edited by willcode4beer : 04-20-2008 at 10:39 AM. |
|
|
|
| Sponsored Links (We share ad revenue): |
| Thread Tools | |
|
|
| Webmaster Resources Marketplace: |
| Software Development Company | Webhosting.UK.com |
| Web Templates | Text Link Brokers | Stock Photos |