|
|

SSI - Server Side Includes
Server Side Includes can do alot for your
site. If your ISP (Internet service provider) has it enabled then you should
give it a try.
Akmal Khan Sapay
.2004.12.03.
You have
certainly visited sites with a menu on the left side which is identical on all
the pages. What if you need to change, say, a link on the left menu. Will you
have to change it in all the pages of your site? Terrible eh? Well not at all if
you use SSI.
What are Server Side Includes?
You may have noticed as you browse that some pages end with the
shtml extension instead of the more familiar html or htm. This
is because these pages use Server Side Includes (SSI). Used properly, the SSI
can help make your pages more responsive and can even help make maintaining your
site an easier task.
SSI (Server Side Includes) are directives that are placed in HTML pages,
and evaluated on the server while the pages are being served. They let you add
dynamically generated content to an existing HTML page, without having to serve
the entire page via a CGI program, or other dynamic technology.
But in this tutorial we will be learning about one of the most popular and
useful uses of SSI that is to say, embedding your single menu in all pages. This
means that if you have many pages with the same menu then with SSI you can make
changes in a single menu which will appear in all the pages.
Checking SSI On Your Server
SSI tags are parsed server-side, not by the user's browser. This means that SSI
must be set up on your server for them to work. To test whether SSI is set up on
your server place the following code in an HTML page:
<!--#echo var="DATE_LOCAL"-->
Then try to run this page on the server. If SSI is enabled the current date and
time on the server will be displayed. If this does not work try renaming the
page extension to .shtml instead of .html or .htm. Many servers require this for
SSI to work. If neither of these work, check the source code of your page. If
the SSI tag is still there there is a problem. E-mail the system administrator
and ask him if SSI is enabled.
If SSI is not enabled on your server then you can put your page on some other
servers like for example Hypermart and angelfire.com
Let's
Do It!
I will just give you a practical
example and hope you understand it. Look at the following code, that is what we
call a server side INCLUDES tag.
<!--#include file="ssi_test.shtml"-->
Now go ahead and download the following zip
file. It contains 3 files which you have to unzip and then follow the
instructions below.
ssi test
After downloading them upload them to your server and put them in THE SAME
directory.
Note the file extension of the first file: ssi_test.shtml. This tells the
browser that it is a includes page so it should be parsed. Note also that in .shtml
page we NEVER use HTML tags like <HTML>, <BODY> etc. Only the part you want to
parse (in our case a menu with 7 links) must be there.
Now experiment with the .shtml file and it will appear in both ssi_test2.html
and ssi_test3.html. Add a link, change the color etc and see how it works. You
will be amazed!
Note that the files must
be in the same directory. Otherwise you have to use:
<!--#include virtual="PathToYourPage.shtml"-->
----------------------
Akmal Khan Sapay
Multimedia Editor
Safis Web
----------
See Also:
Playing with Tables
|
.More Sites:
VCD Help
DIVX-Digest
VCD Shop
DVD
Shop
.Visitors'
Corner
Submit your article
Send
your Question
.Download Movies
Pirate
Bay
Torrent
Reactor
Live
Torrents
Torrent
Spy
.Dig
deeper into SW
Afghanistan
Site
Lagman
Site
.Enter Forum
|