Free Webmaster Help Logo
Tutorials Articles Tools Images Directory Ask Newsletter
*
 

Tutorials
Cookies
ASP
Advanced HTML
Frames & Tables
.htaccess
Rounded Table Corners
Flash 5
FTP
Beginners
Javascript
PHP/MySQL
Site Promotion
Mobile Internet: WML/WAP
Server Side Includes (SSI)
HTML - The Basics
XHTML
Stylesheets
XML
PHP
*

125x125

Related Links
Free SSI Hosts
More Server Side Includes (SSI) Sites
*

 
Sitemap | Contact | Link To Us | Advertise
Report A Problem

Server Side Includes (SSI) Tutorial
Part 2 - Scripts & Preset Commands

Introduction

In the last part I explained what SSI is and what it can be used for. In this part I will show you how using it with a script is useful and how you can include certian information into your page.

Scripts

One major use of SSI is to include the output from a script in your page. As I explained in the last part, the adverts a the bottom and side of this page are placed there using SSI. There is a very simple CGI script which, every time it is run, generates the code for an advert to place on the page.

This file is then called via a standard SSI call (like for any other file) with a slight change (although 'include virtual' usually also works):

<!--#exec cgi="/cgi-bin/clicktrade.cgi" -->

As well as for advertising rotation, SSI can be used with many other scripts, for example to display a textual visitor count on your page or to do an image or text rotation on a page of your site. It can even be used in conjunction with a content gathering script to seamlessly integrate it into your pages.

Preset Commands

SSI can also be used to display information on your page which is preset by the server. One of the major uses in the date and time command which is used as follows:

<!--#echo var="DATE_LOCAL"-->

which appears like this:
Friday, 12-Apr-2002 11:03:34 EDT
(this is not a live example, the true system time would be shown on a real ssi page)

This is the date and time on the server your site is hosted on. You can also display the date and time time in GMT using:

<!--#echo var="DATE_GMT"-->

The format the date and time appear as may not be what you want so you can format it using the 'Timeformat' command before the date command, for example:

<!--#config timefmt="%A, %d %B %Y"--><!--#echo var="DATE_LOCAL"-->

which will display:
Friday 12 April 2002
(again this is not a live example)

The time format is made up of some codes which you can separate as you want them to appear (like the comma I used above). Here is a list of some of the codes you can use:


CodeFunctionExamples
%AFull weekday nameMonday, Wednesday
%aAbbreviated weekday nameMon, Wed
%BFull month nameJanuary, December
%bAbbreviated month nameJan, Dec
%dNumber of day in month03, 1500
01/font>
%eNumber of day in month 3, 15
%HHour (1-24)05, 22
%IHour (under 12)03, 11
%jDay number in year12, 245
%mNumber of month1, 12
%MMinute12, 59
%pAM or PMAM, PM
%nNew Line
%SSecond 12, 57
%tTab
%y2 Digit Year99, 03
%Y4 Digit Year1999, 2003
%ZTime ZoneEST, GMT

As well as the time there are several other preset commands you can use inc
luding:

Document Name (the file's name):
<!--#echo var="DOCUMENT_NAME"-->

Doucument's URL (the part after the domain name)
<!--#echo var="DOCUMENT_URI"-->

Refering Page:
<!--#echo var="HTTP_REFERER"-->

Users IP Address:
<!--#echo var="REMOTE_ADDR"-->

There are some others as well, although these are the most useful.

What Next

Now you have learned the basics of using SSI you will probably find that you can't do without it! If you want to find out some of the other preset commands in SSI you can do a search on your favourite search engine.

© 1999 - 2001 FreeWebmasterHelp.com