courses   |   sign up   |   materials   |   instructor   |   jobs   |   email   

text link
read/watch link
homework link
grades link
examples link
resources link
faq link
syllabus link
  
    home link

LESSON 7: SERVER SIDE INCLUDE COMMANDS

Objectives
    o SSI defined
    o environmental variables
    o include command
    o updating SSI files
    o execute command

Overview

Server side includes have saved me hundreds of hours, ensured that my site is accurate throughout, and created clean Web pages with much less code. How do they work?

First, take a look at the content of your pages and identify which elements are repeated on every page. If the same group of links or the same contact information is included at the bottom of 100 Web pages, wouldn't it be a time saver to create a single file called "bottom" that contains the text and links? Next, you would remove the links and contact information from the 100 HTML documents and substitute a single line of code that refers to the "bottom" file:

<!--#include virtual="bottom"-->

That may seem like more work than just writing each page from top to bottom, and it is … until you have to change something. Let's pretend you have 100 products pages and you need to change the refund policy that appears at the bottom of every page. Here are the steps involved in changing the pages without SSI:

  1. Download all 100 pages
  2. Open each file
  3. Find the old refund policy and replace it with the new
  4. Save each file
  5. Upload all 100 pages
Compare that with the steps involved in changing a site with SSI:
  1. Download the file called "refund"
  2. Change the contents of the file
  3. Save the file and upload it
Because I am using server side includes, I can change 100 files by modifying only one file.

If this concept sounds familiar, that's because it is. Cascading style sheets allow you to link to an external .css file and control the look of 100 documents. Server side includes allow you to use the linking principle to control the content of 100 pages. The principle of controlling a collection of documents from a single file is employed in both server side includes and cascading style sheets. As your site becomes larger, these technologies will make it much easier to maintain and modify.

Have you ever visited a Web page that displayed the current day's date and time or the date a file was last modified? Been scratching your head over how they can do that? Well, SSI code is the answer. The server constantly keeps track of the date and time and is happy to display it on your page, if you just use the SSI code correctly. The server also keeps track of the date you last uploaded a file onto the Web. If you have materials that are time sensitive, displaying the date on which the information was last modified can be invaluable.

Finally, we will use SSI code to create a simple counter. This code will cause the server to execute a simple Unix script that increases a file by "1" every time your page is hit. The code also displays the contents of this file on your Web page.














































 
lessons|| reading|| homework|| grades|| examples|| resources|| faq|| syllabus

instructor contact information
c. sumner - chaela@webgoddessdesign.com
c. massell - cmassell@santarosa.edu

copyright 2005 linda hemenway