Managing Navigation and Ads with Server-Side Includes
Consistent navigation is a key component to making your content accessible. Weighing the various options, I felt that, on a site this large, it might be helpful to pull that navigation out into a SSI. This way, any changes to that navigation can be made to just one file instead of the thousands files that reside on the site.
WebReview.com sits on an Apache server using OpenBSD as its OS. On this setup, it's possible to use SSIs to address multiple concerns. With an SSI, you can insert an include statement that asks the server to supply a snippet of code in place of the include when the page is served. It's an awesome technology when you're trying to manage large sites.
In the case of WebReview.com, SSIs helped me find solutions, such as navigation consistency, easy update access (the navigation SSI is one file and changes made to it apply to the entire site), and a means to separate the advertising markup from our own markup. The ad markup requires regular updating, so it makes sense to use SSIs.
Of course, different servers use different include methods. The one WebReview.com uses is fairly common. You can check with your hosting service for details. Otherwise, the following method is fairly general.
To view the include file, simply open it in an editor.
Figure 3.7 Viewing the contents of the include file in an editor.
To better understand an SSI:
Open master_document.html and find the navigation section, under the begin left navigation comment tag.
It should begin with the following:
<!-- begin left navigation --> <font face="verdana, helvetica, arial, sans-serif" size="2"><b>SEARCH</b></font> <form method="get" action="/cgi-bin/atomz"> <font face="verdana, helvetica, arial, sans-serif" size="2"> <input type="text" name="q" size="8" value="" /> <input type="submit" value="go!" /></font> <br /> <font face="verdana, helvetica, arial, sans-serif" size="- 2">search sponsored by<br /> <a href="/cgi-bin/tracker?SRC=wt_atomz&URL=http://www.atomz.com/go/ webreview" target="_new">Atomz.com</a></font> </form> <font face="verdana, helvetica, arial, sans-serif" size="2"><b>INSIDE</b><br /> <a href="/index.shtml">Current Issue</a><br /> <a href="/columns.shtml">Columns</a><br /> <a href="/offline/2001/05_18_01.shtml">Offline</a><br /> <a href="/archives.shtml">Archives</a><br /> <br />
Compare this to the file master_include.inc.
<tr> <td width="160" valign="top" align="left">
Notice that the navigation section and the include file contain the exact same markup, including portions of the table that's necessary to make the include fit accordingly into the main document, such as the following:
All the navigation code has been removed from the originating file, and replaced with the include statement, which you see how to do now.
Open master_include.shtml, and note the include statement:
<!-- #include virtual='/includes/nav.inc' -->
This document has the include statements that you'll create and use on your site. The server will then input the markup automatically. When you call up the page and view source, you'll notice that the source displays completely. You don't see the include statements because the server already processed the document.
Although SSIs are familiar to some readers, others haven't had the opportunity to explore them. It's an old, standard practice that's extremely efficient. As you can see, we were able to create one in a few steps. Yet, the way they work adds much power to the developer by controlling numerous pages with a single filesimilar to a style sheet. The main challenge for those readers who want to try out SSIs is this: Be sure that you find out from your server administrator how they are properly achieved on the particular server that you are using. Sometimes, this information is available on your ISP's web site. In some cases, you unfortunately might not have access to include SSIs at all.