|
|
|
|
|
|
|||
![]() |
|
|
|
An easier way to manage pages in your site is by replacing chunks of repeating code, such as your navigation links, with server side include (SSI) files. Instead of repeating the same code over and over, you create a separate file with just that chunk of repeated code in it, then place a line of code on each page that tells the server to insert the contents of a separate file into that spot on the page.
When someone visits your page, the server scans the code, pulls in the files needed to assemble that page and returns the page as a single, complete page to the browser. Your "includes" code is replaced by the contents of the file the code called. Since this all happens on the server's side of the transaction, your visitors don't need to have any special browsers or plug-ins in order to make this work; SSI returns a "normal" html page to the browser. SSI files can simplify the maintenance of your site. Information that may change from time to time or that replicates across many pages can be replaced with SSI files. Then, when you alter that include file, every page on your website changes where the included file is being read. You will find include files often being used to replace the entire header and footer for each page. When set up as includes, the background color, graphics, navigation, or copyright information can be changed across the entire site by altering the include file for that information. Without includes, you would be forced to go through all your pages to make the necessary changes. You can use as many includes files on a page as you need- you can also call different includes files for different pages. A good example is subnavigation links that only appear on certain pages, you only call that include file where it's required. Any block of code in your site that repeats across pages is a good candidate for SSI.
The format for the code you will use to include a file within an Html page will depend on the operating system of your server. For most sites, this will mean either Windows or Unix/Linux. If you are using Windows, you'll be changing your file extensions to .asp. For Linux/Unix systems, you will use .php extensions. You should check with your web host or server administrator if you are not sure what platform your site is hosted on. Here are the two standard file include methods for both Windows and Linux systems (Note: you must use the proper file extensions [.asp or .php] in order for these functions to work.) Remember, the included file will process just as regular Html; all you are doing is splitting your pages into manageable parts for easy editing and maintenance: Windows (.asp) <!--#INCLUDE FILE="header.asp"-->
1. Create a file called header.asp that only contains the code that you want to include.
Linux/Unix (.php) <? include("header.php"); ?>
1. Create a file called header.php that only contains the code that you want to include.
In both cases, relative paths can be determined as in HTML, such as: <? include("../header.php"); ?> or you can use an absolute (full) path, which is ideal for sites that have multiple levels of folders in their structure: <? include("http:www.site.com/header.php"); ?> Changing the extensions of your pages can be a temporary headache, especially for established sites but in the long run, the ease of maintaining and changing the site is worth the effort. Before changing page extensions, be sure to have a custom 404 error page in place. (Most hosting packages today offer custom 404 page tools in their control panels- contact your host if you don't see an option in your hosting control panel.) SSI gives you the flexibility of a framed site without all the usability issues that come along with frames. It allows you to separate the page content from the structure and graphics, giving you the freedom to easily change any consistent element of the site without a major hassle. It's worth changing existing sites and should definitely be considered when planning a new site. Editorial Note: For additional information on Server Side Includes, you can visit the following websites:
WDVL.com
![]() Printer Friendly Version of this Article
Download the Fr'ee Alexa Toolbar
The Insider's Guide To Dominating the Search Engines
Want a Simple Explanation of
How to Make Mon'ey Online?
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
| SiteProNews - The Net's most widely read Webmaster newsletter | |
|
|
|
Best-SearchEngine.com Previous SPN Tips of the Day AllBusinessNews.com | |
|
GoArticles - Search 17,200+ Articles MetaWebSearch - Search Top Engines EzineHub - Search 6,200+ Newsletters |