Page

11.3.1- Structure of the Content Linking Component

Created by Brendan Doss.
Last Updated by Brendan Doss.  

PublicCategorized as 11. Active Server Pages Components.

Not yet tagged
<< 11.3.0- The Content Linking ComponentChapter1111.3.2- ASP Pages that Use Content Linker to Hyperlink to the Next Page >>

Structure of the Content Linking Component

The content linker has two parts:

 

  • The index file. An ASCII text file that holds a list of .asp pages, in the order that they should be presented to the viewer. The index file can easily be changed to add new pages, revise the order of pages, or substitute newer pages for older pages.
  • The ASP pages. Each .asp file contains two parts. The first part consists of the normal content of the page, such as the text and graphics. The second part is the ASP code that uses the Content Linker to give the user options for moving through the list of pages. These options are typically hyperlinks for the Next Page, Previous Page, First Page, and Last Page.

 

Although most people refer to this component as the Content Linking or Content Linker component, in IIS5 it is referred to as NextLink. For our purposes, the two terms will be used interchangeably.

Using Content Linking

Over the next few pages, we will build several examples of increasing complexity, but let's start here by looking at an example that doesn't even use ASP. Consider the HTML page shown below, which displays information about the first item on our tour of new products – hat model #501. We'll refer to this as CL-less-Hat501.htm, the CL for content linker. You can try making this page, but it is not required for the other exercises of this chapter.

 

<HTML>

<HEAD>

<TITLE>Hat with no content linking</TITLE>

</HEAD>

<BODY>

<P>Hat of the Week:</P>

<P>Featuring an expanding elastic rim</P>

<A href="CL-Sweater.asp">Click here for next item</A>

</BODY>

</HTML>

 

At the top of the page, the user will see text that describes this hat; at the bottom of the page, there is a hyperlink which, when clicked, takes the user to the next item on the tour of products (in this case, the page describing sweater #304). In this context, what we're really interested in is the site navigation technique. Here's the line that should jump to our attention:

 

<A href="CL-Sweater.asp">Click here for next item</A>

 

In this first case, the HREF to the next page is hard-coded: that is, it's typed in raw HTML. Note that the target of the HREF attribute must be in double quotes. Provided you've already created the target page CL_Sweater.asp, the user will have no problem with this.

 

However, when it is time for the web master to make changes to the order of the pages, he will have to dig through every page, find each of these Next hyperlinks, and write in the new HREF. It's a laborious task (believe me, I've done it); and it's also very confusing, since there is no stage at which the web master ever sees the whole list of pages on the tour. This problem can be neatly overcome by using the content linker which, in turn, uses the index file containing the full list of the tour.

A note on the files used in the Try It Outs for Content Linking

We will be creating a site with four pages of clothing products which we want the visitor to tour. Our focus in this section will be on the code to navigate from page to page. We will put all of the code for navigation into a file called "CL-Navigation.asp" which will be included as a footer in each product page. In this way we only have to make changes in one place and they will apply to all pages. At the end we will add a table of contents page. So the files in the next table will be created and modified. Note that each file name begins with CL- so that they stay together in an alphabetical listing of files in your BegASPFiles directory. There is no other purpose to the naming. Note that we will be making several improvements to the navigation footer file. I suggest you keep the old ones so that you can review the simpler versions of the code. You can name them CL-Navigation01, CL-Navigation02, etc., but your currently utilized file will always be the one named simply CL-Navigation.asp.

 

File

Purpose

Type

File Name in the Try-It-Out

Index File

Hold list of pages and order to visit

DOS

ASCII text

CL-NewProductsTour.txt

Navigation code file

Page that holds the navigation code which is included as a footer in each page on the tour

.ASP

CL-Navigation.asp

Web pages

Pages on the tour which utilize the content linker

.ASP

CL-Hat.asp
CL-Sweater.asp
CL-Tie.asp
CL-Trouser.asp
CL-vest.asp

Table of Contents Page

A page with code to demonstrate building a TOC from a Content Linker Index

.ASP

CL-TOC.asp

Content Linker Index File

A good first step in creating a tour of our pages is to build the Index file. After creating an index file in this Try-it-Out we will create pages for sweaters, hats, trousers, etc. in the next
Try-It-Outs. Eventually, each page will have 'next' and 'previous' buttons to guide the visitor through the tour.

Try It Out – Creating an Index File

We first need to construct the index file. We will be using this file in our examples, so it is important to create it exactly as shown below.

 

1.    Start your text editor and create a file with one line for each URL that will be in the tour of pages. Save this file in your BegASPFiles folder, giving it the name CL-NewProductsTour.txt. Note that to make troubleshooting a little easier, I have put the pages in alphabetical order.

 

CL-hat.asp This Week's Hat Run for Sept 01-08 2001

CL-sweater.asp This Week's Sweater Run for Sept 01-15 2001

CL-tie.asp This Week's Tie Run for Sept 01-08 2001

CL-trouser.asp This Week's Trousers Run for Sept 01-23 2001

CL-vest.asp This Week's Vest Run for Sept 01-15 2001

 

It's important to format this file correctly, so separate the entries on each line with a Tab – nothing else – and press Enter at the end of each line, to start the new line. Hence, each line should be typed as: URL Tab Description Tab Comments Enter. The URL does not need to be prefixed with http:// provided you intend to store the page in the same directory as the other pages. The order of the entries from top to bottom determines the order that the visitor will be guided through the site.

How it Works

In the lines of the index file, we have created three columns separated by tabs:

 

  • URL column
  • Description column
  • Comments column

 

The URLs are the files that are contained in our tour of pages: we must list them in the order in which we want them to appear in the tour. The contents of the Description column will be used later to give information to the user. The contents of the Comments column will only be seen by the site designers when they look at the index file. The Comments column is optional. You can add various comment lines such as a title for the file, comments or a revision date.

Common Errors with Index files

  • Adding more than one tab between the columns
  • Using spaces between columns rather than the required tab
  • Forgetting to save the file to the BegASPFiles folder
  • Forgetting to put the file extension (for example, .asp) on the file names in column one
<< 11.3.0- The Content Linking ComponentChapter1111.3.2- ASP Pages that Use Content Linker to Hyperlink to the Next Page >>

Copyright © 2003 by Wiley Publishing, Inc.

Powered by Near-TimeTerms of Services | Privacy Policy | Security Policy |