|
There are several parts of this site which contain changeable
information which are displayed many times over across many
different pages, for example the left hand menu on this page
also appears on every page in the 'Site Maintenance and Help'
section. Should any changes need to be made to this menu (adding
or removing a link for example) it would involve altering
EVERY page is this section and would be extremely time consuming.
Server side includes offer the ability to link to one file
which is then included into whichever page calls it. This
means you can update just the one file and all pages linking
to it will see the change.
So using the example of the left menu on this page it is
actually a file called menu.html
located in the /sitemaintenance
directory. Every page in this section links to this one file,
displaying it in the left menu space.
| About Server Side Includes |
This is not essential information but will help you to understand
what a Server Side Include is.
Server Side Includes are not regular HTML files in that they
do not need header or body statements, they use the header
and body statements from the documents they are included in.
The best way to think of them is as chunks of text which are
simply cut and paste into the page in the place where included
is called from. Includes are processed by the web server first,
so effectively the server takes the text that is held in the
included file and pastes it into the location of the include
command then proceeds to read the entire page as a complete
HTML page. If you were to view the source code of a page containing
Server Side Includes served from a web server it would look
no different from a page that didn't contain Server Side Includes
as the web server has already processed the Includes prior
to sending the page to the browser.
For an easy to follow example take a simplified version of
the header section on each page of this site.
Code before it's processed by the web server :-
<head>
<!--#include virtual="/eurofighter/includes/pgtitle.htm"
-->
</head>
As you can see the syntax for calling an include is <!--#include
virtual="path from web server root to the file to be
included " -->, in this case we are including
a file called pgtitle.htm, this
file contains just one line :-
<title>Eurofighter Simulation Systems</title>
When the web server processes the <head></head>
section of code it will take the contents of pgtitle.htm
and place it onto the HTML page in place of <!--#include
virtual="/eurofighter/includes/pgtitle.htm" -->,
with the finished HTML code displayed by the web browser being
:-
<head>
<title>Eurofighter Simulation Systems</title>
</head>
With every page including the file pgtitle.htm
in place of the actual <title></title>
statement in each page's header you can now alter the title
of every page in the entire site by editing one line of text
in the file pgtitle.htm. This
should give you some idea of the true value of using Server
Side Includes.
| Server Side Includes used
on this site |
To ease updating and save time this site uses several Server
Side Includes, some unique within each section and others
globally used throughout the site.
Note : All include files in this site are
denoted with the extension .htm, this extension is not used
for any other type of file.
|
Server Side Includes used Globally
|
In the /includes directory
in the site root you'll find all the gobal Includes used
throughout the site. These are :-
bottomlinks.htm - displayed
at the bottom of every content window except on pages
in the root of the site. Contains links to the top level
pages (TTSL home, FAQ, Feedback and Sitemap) also contains
a link to go back to the previous page.
footer.htm - holds the page
footer which contains links to the Bulletin Boards.
pgtitle.htm - included in
EVERY page in the site, this file sets the page title
which appears at the top of the browser window.
|
Server Side Includes Unique to a specific section
|
The main SSI used within each section is the left hand
menu, menu.html. This menu,
located in each sections root, holds navigational links
and is displayed on each page within the left menu section.
There are some which are unique to only one section :-
back.htm - this include
takes the place of bottomlinks.htm
at the foot of each content window for every page in the
site root (i.e. the pages that bottomlinks.htm
would have ordinarily taken you to) providing a link to
take you back to the previous page.
|