Server Side Includes (SSI) allow web administrators and developers to add dynamic content to live web pages which are generated from scripts. These queries can add important functions such as IP address, times and various types of information that can be customized to a particular user. Heavy use of SSI commands can slow load times on pages, while moderate user can provide valuable customizations.
In order to utilize server side includes users must have a mod_include module active on their Apache server and enable the module via an Options +Includes setting. Many configuration files have options lines referring to various directories – in some cases you may have to add an include function for the various writeable directories on your server. Importantly, for security reasons Apache also requires delimiting which types of files should be processed with SSI commands. For example if you want to enable server side includes on html files you would add the following lines to your configuration file:
AddType text/html .html
AddHandler server-parsed .html
When adding server side includes to standard HTML web pages, you can call the element and variable to display dynamic information in this format:
<!--#element variable=var attribute=value-->
With this basic format you can call the local time, location or the results from a CGI script program. For example, you might want to let a reader know they’re the Nth visitor to your site via a basic include function from a cgi-bin script, or show them their local time in a particular time format attribute. You can display virtually any combination of functions in this way, and SSI functions can help you automate development tasks in static HTML sites.
For example, suppose you want to include a basic header and footer across all of your pages. While modern templating systems make this easy, you can implement the feature in standard HTML sites with a few basic functions:
Another great use for SSI coding is to condition the display of your pages based upon a user’s technology. For example, older version of Internet Explorer may not have fully enabling modern Javascript or Flash features. You can, therefore, display alternative files or text in place of these features when you notice the user lacks modern browsers. Firstly, make sure to add this identification to your configuration file as:
BrowserMatchNoCase MSIE InternetExplorer
This helps your server identify the client’s browser and you can then implement conditional Javascript code. In these situations, the conditional code will ensure information is properly displayed so the user gets a seamless experience:
This particular page doesn’t render in Internet Explorer. We recommend upgrading to the latest version of Firefox. Javascript code for Firefox users
Based upon both absolute and conditional code, you can implement a wide range of features within your web pages that call dynamic content. When it comes to making your HTML pages more dynamic, mod_include functions can help bring your site to life.
0 responses so far ↓
There are no comments yet...Kick things off by filling out the form below.
Leave a Comment