Server Side Includes (SSI)

8:43 PM Posted by BlogTechno

What are Server Side Includes?

Server Side Includes are files that have some commonly used code that can be reused by many pages in your site. When you use a SSI file the server takes the entire content of the file and inserts it into the page, replacing the include code. As an example, imagine you have a large portal web site with links at the top, bottom and sides common to all pages (or a section of pages). To make the site easy to maintain you can have the header, footer, right menu and/or left menu as include files. So when there is a change to be made you just need to make the changes, save and upload the corresponding include file and not the many files using it.

How are Server Side Includes better and different from frames?

Though frames are sort of similar to Server Side Include files, we do not recommend their use as not all browsers support them. In frames each frame is a separate page with its own tags (unlike SSI where they cannot have these tags) and is called in the main page where the frames are defined.

Create your own SSI file and call it by using the given code

Create a file which contains the reusable code with the extension .htm, .html, .asp or .php

Very Important: If you are using highly confidential ASP/PHP code (or any other web technology), like your database connection string or some business logic, in your include file then make sure the include file is named .asp/.php so that no one can open the include file and see your code.

You cannot use include files in HTM or HTML files, You can use them only in SHTML, ASP, PHP pages, etc. - that support include files.

Now go to the page that will use the include and add the following code in the appropriate place:

SHTML or ASP:
PHP:

Calling Server Side Includes into your page using Macromedia Dreamweaver

In your page, keeping your cursor in the place where the include file should come, Click on Insert > HTML > Script Objects > Server Side Includes (for MX 2004) or Insert > Server Side Includes (for Dreamweaver 4). In the pop-up window that appears select your include file, give the path as relative to Site Root (for ASP) and click OK.

Related Posts :



0 comments:

Post a Comment