Halaman

Selasa, 13 Juli 2010

How to Update Multiple Web Pages Using Server Side Includes

SSI (Server Side Include) is a simple and robust way to include
common content in multiple pages. In a similar way to the client-side JavaScript method, SSI involves having a separate file which contains the content you wish to appear on multiple pages. To update the content, you only need to edit a single file.

Pros:
  1. Server-side is safer than client-side (it doesn't rely on any
    browser settings).
  2. Updates are very fast and easy.

Cons:

  1. Slight performance overhead at the server end (every SSI page needs
    to be processed by the server before it is served to the user).
  2. You usually need to use a special extension for web pages, e.g. .shtml.
  3. The server must support Server Side Includes (most Apache servers
    do).



Step 1: Create the SSI File


Create a plain text document and name it with a .txt extension, for example navigation.txt. Save
this file in a folder which is accessible from your whole website. You  may want to make a special folder for this type of file, e.g. /includes/.

Into this file, enter the content you want to be displayed on every  page, for example:


<div style='color:blue; font-size:12pt;'>

<a href="page1.shtml">Page 1</a> | <a
href="page2.shtml">Page 2</a> | <a
href="page3.shtml">Page 3</a>

</div>


Step 2: Insert the SSI Code into Your Pages


On each page, at the point where you want to the content to appear,  place the following code:

<!--#include virtual="/includes/navigation.txt"
-->

To update the content, simply edit the main SSI file and all pages  will automatically update.



Notes:

  • In most cases you will need to change the file extension of your web
    pages to.shtml. If this doesn't work, ask
    your provider for help.
  • If you're creating your pages on a home computer, the SSI includes
    will not show up unless you're running a personal web server. You will
    probably need to upload the pages to your website before you see it all
    work properly.


Tidak ada komentar: