Syndicate content
> Make Life Easier with Shared Page Elements : Home-grown solutions

Make Life Easier with Shared Page Elements : Home-grown solutions

Introduction
Home-grown solutions


Home-grown solutions

Not using a web authoring tool? Even if you're the programmer type with an unnatural affinity for Notepad you can use shared page elements. Essentially you'll create separate text files that contain the code for shared page elements, and then call upon these files as needed.

The most common way of doing this is with server-side includes (SSI). Create separate HTML files for each shared page element. For example, you might have an HTML file called "banner.htm" that's been saved in a directory called "includes".

In the HTML file for each page, add the following line:

<!-- #include virtual="/includes/banner.htm"-->

When the server opens an HTML file on your site and sees this code, it grabs your banner code and merges it with the other HTML code on the page. The beauty of this is that you can use this include over and over. When you make a change to the banner.htm file, that change is propogated throughout the entire site (at least for every page where you've called the banner file.

Note that your server must be set up to process SSI. Contact your server administrator if you have questions.

PHP is a scripting language which excels at the dynamic delivery of web content. We use it extensively at WEBtheJOINT.com. Similar to SSI, you can embed code in one file to bring in page elements stored in another file.

Instead of using .html or .htm files, PHP uses the .php extension for files containing PHP and embedded HTML code. To "include" your banner code, place a command like this in your php file:

<?php include("/includes/banner.htm"); ?>

Summary

If you're not using one of these approaches, you probably should be. It allows your content managers to focus on what they do best -- creating and updating content -- without having to worry about recreating common page elements over and over. As with any change in process, anticipate a learning curve, but also be ready for the benefits of a more efficient process and a cleaner web site.
Keith Reichley
www.webthejoint.comKeith Reichley is webmaster for WEBtheJOINT, the web resource center for small business. Contact Keith at keith@webthejoint.com.

User login

Christian-Web-Masters.com newsletter

Stay informed on our latest news!