|
by Leo A. Notenboom |
Server side includes (or "SSI") are a way to include the contents of one file into another. For example when this line in a .html page is processed by a web server that supports SSI:
<!--#include "text.inc"-->
It is replaced with the contents of the file "text.inc".
Server side includes are perfect for text on your blog pages that do not require any MovableType directives or variables and that you might want to change without rebuilding.
Take a look at this example from the Ask Leo! home page from some time ago:
The only thing not in a server-side include is the actual article "Is My Email Account Private?". The rest comes from the following server-side includes:
Why do I make such heavy use of server-side include files? Two reasons:
1. Items like the page header, which might be used on several different pages, need only be written once, and used everywhere. Changing the include file immediately changes the appearance of all pages that use it.
2. No MT rebuild is required to make a change. If I want to change my "Top Story", for example, I simply change topstory.inc, and the page contents are immediately changed. No rebuilds, no MT involvement whatsoever. It's likely that if you visit Ask Leo! today, the home page may look quite different than the snapshot above, as I change it over time.
Using server-side includes in MT is easy: just put them in your templates. For example, here are a couple of snippets from my index.html template:
<body> <!--#include FILE="header.inc" --> <div id="content"> <!--#include FILE="topstory.inc"--> <div class="blog"> <a name="blog"></a> <MTEntries lastn="15">
You can see that my body starts with an include of the header.inc file, and the content div begins with the include file containing my top story. After you've built your site to use them, when those pages are diplayed in a visitor's browser, those lines will be replaced with the contents of the files they reference.
Posted February 12, 2006
Site Map
Entire site Copyright © 2003-2008,
Puget Sound Software, LLC and Leo A. Notenboom
Terms, Conditions & Privacy