Handling Repetitive Content Like Site Navigation

 

Very frequently you will find yourself inserting the same content into web pages the most common case being the page navigation.

The problem arises when it changes.

For example imagine we have the following simple navigation on 20 pages of our site.

Home|Contact

Now what happens if we want to change it to

Home|Contact|articles

Well we will normally need to hand edit all twenty pages.

 There are however ways to overcome this.

Method 1

Use an editor like FrontPage that support find and replace across multiple pages.

Method 2

Use a web editor that supports content includes. FrontPage supports this using a webbot. 

Method 3-Use JavaScript

 Although Javascript is often used for adding content from other sites (like Google adwords) it is not so popular anymore for menus. The reason is that search engines don't normally follow JavaScript links.

Therefore I won't consider this further .

Method 4- Use Sever Side Scripting Like PHP or ASP

This method is very power but requires that your website host supports the scripting language (most do).

To illustrate how powerful scripting like PHP can be for including content I am going to create a web page entirely from included files.

 In effect I will be creating the beginnings of a content management system.

What you will see here you will see in systems like Wordpress and Joomla etc, however they are much more complex.

The workhorse is a simple PHP include statement as you will see. What I am going to show is a simple web page split into three components

Header   -uses Page header.php
Main content  -Uses page main.php
Footer  - uses Page footer.php

Here is the Index.php that pulls the pages in:

<?php


include("header.php");
include("main.php");
include("footer.php");

?>
 

See how simple it is. Here are the three pages that it includes:


header.php

<html>
<head>
<title>the is the page title</title>
</head>
<body>
To menu bar


Main.php

<P>Main part of the page goes here</P>


Footer.php

Copyright
</body>
</html>

Here is what it looks like when you open the index.php page

Method 5 -Server Side Includes (SSI)

Server Side Includes (SSI) are sometimes classed as  server side scripts, but they are really a collection of specially embedded commands.

They are not as powerful as scripting options like PHP and require server support.

Method 6-Use Images

This is a very powerful and simple technique. You just convert your text into an image object and insert it in the page.

Resources: