Wise ASP Logo Surfer's Choice Member
   

Wise ASP - Using the Content Linking Object

One complaint about the World Wide Web has always been that all sense of order is lost. Users are free to click on any link they like, and the order in which material is followed in not necessarily the order intended by the author. Fortunately, the Content Linking component gives you an easy way to link pages in a site and maintain that linkage in the future.

Create the Text File

The Content Linking component is a very useful tool for sites that provide contents pages, or pages that contain a list of links to other pages on the same site. And because the details are stored in a text file, maintaining the site and links between the pages becomes a matter of just editing the text file. For example, you can change the order that the pages are displayed in, just by rearranging them in the content linking list file. The file contains one line text for each page. Each line consists of the URL, description and comment, separated by the TAB character and ending with a carriage return. For example:
cars/default.asp Buy A Car 
cars/cars.asp Choose a car 
cars/financing.asp Choose a financing plan 
cars/delivery.asp Do you want us to deliver your car? 
cars/feedback.asp Tell us about our service 

Create A Drop Down Box

Let's use an HTML drop down box as a navigational tool on Car Web site The drop down box will contain all available web pages and will be included on every Web page. First, you will create the NextLink object. Next, you need to tell object where your Web pages are defined. You will use the Count method to determine the number of links. So you can dynamically create your drop down box, regardless of the number of Web pages listed in the definition file. You will use JScript's for loop to retrieve each link and its properties from your file. The main portion of a SELECT tag is the OPTION tag. You will use GetNthURL to get the URL from your file defintions and populate the VALUE attribute. And you will GetNthDescription to display text in your drop down box. The for loop will continue until all of the Web pages have been read from your text file. Finally, you will close the SELECT and FORM tags and your drop down box is ready to go.

<% 
var nextLink = Server.CreateObject("MSWC.NextLink"); 
var strListFile = "cars.txt"; 
var nLinkCount = nextLink.GetListCount(strListFile); 
Response.Write("<FORM NAME=goBox METHOD=post ACTION=" + Request.ServerVariables("script_name") + ">"); 
Response.Write("<SELECT NAME=jumpto>"); 
Response.Write("<OPTION VALUE="wiseasp">-- You can jump directly to --</OPTION>"); 
for ( var i=0; i<nLinkCount; i++ ) { 
  Response.Write("<OPTION VALUE=" + nextLink.GetNthURL(strListFile, i) + ">"); 
  Response.Write(nextLink.GetNthDescription(strListFile, i)); 
  Response.Write("</OPTION>"); 
} 
Response.Write("</SELECT>"); 
Response.Write("<input type=submit value='Go'>"); 
Response.Write("</FORM>"); 
%> 

You can also any of the other HTML tags to create a way for users to to easily navigate your Web site.

The Content Linking Component

PropertyDescription
GetListCount(list)Returns the number of pages in the file list.
GetListIndex(list)Returns the position of the current page in the file list.
GetNextURL(list)Returns the URL of the next page in the file list.
GetNextDescription(list)Returns the description of the next page in the file list.
GetPreviousURL(list)Returns the URL of the previous page in the file list.
GetPreviousDescription(list)Returns the description of previous page in the file list.
GetNthURL(list,n)Returns URL of the nth page in the file list.
GetNthDescription(list,n)Returns the URL of the nth description in the file list.

  That's the end. Feel free to cut and paste this code and use it yourself. Thanks for reading and feel free to jump around Wise ASP using the select box at the top of the screen.

Related Information

88x31cardsvisoranm