The Content Link component (linking) is used to create a content link (nextlink) object that manages a list of URLs that automatically generates and updates the navigation links for the table of contents and previous and subsequent Web pages. The steps for using the content-linking component are as follows:
1 Create a Content link (nextlink) object instance;
2 Create the Content link list file;
3 Use the method of Content link (nextlink) object to generate navigation links.
1. Create a Content Link object instance
The Content link component is included in the Nextlink.dll file. When you use a Content link component, you first create a content link (nextlink) object instance based on that component. The syntax format is as follows:
Set NextLink=Server.CreateObject("MSWC.NextLink")
Where the parameter nextlink specifies the name of the object created by the Server.CreateObject method. The method does not have a registry key.
2. Create a linked list file
To use the Content Link component (linking), you must first create a linked list file (content Linking list). It is by reading this file that the Content link component obtains and processes information about all the pages we want to link to. In fact, the file is a plain text file that must be used on the WEB server's virtual path. The Content Link list file contains one line of text for each URL in the list, each line ends with a carriage return, and each item in the line is tab-delimited. The syntax format is as follows:
Web-page-URL [text-description [comment]]
Note: Where the Web-page-url parameter specifies the path to the Web page to link to, it can be a virtual or relative URL of a Web page, and does not support absolute url;text-description parameters that start with "http:", "//" or "\" Web-page-url The descriptive text comment gives the annotation text, and the Content Link component does not process the text.
3, retrieve the Content link list file
A content-linked file provides a series of methods that you can use to get the URL, descriptive text, and other related information for a Web page from a content-linked list file. Use these methods in an. asp file to automatically generate a navigation link for a Web page. The description of each method is shown in the following table:
Method |
Description |
Syntax format |
GetListCount |
Gets the total number of Web pages listed in the Content Link list file. |
GetListCount (listURL) |
GetListIndex |
Gets the index number of the current item in the Content Link list file. |
GetListIndex (listURL) |
GetNextDescription |
Gets the descriptive text for the next item in the Content Link list file. |
GetNextURL (listURL) |
GetNextURL |
Gets the URL of the next item in the Content Link list file. |
GetNextURL (listURL) |
GetNthURL |
Returns the URL of an item in a Content Link list file. |
GetNthURL (Listurl,i) |
GetNthDescription |
Gets the descriptive text for an item in the Content Link list file. |
GetNthDescription (Listurl,i) |
GetPreviousDescription |
Gets the descriptive text for the previous item in the Content Link list file. |
GetPreviousDescription (listURL) |
GetPreviousURL |
Gets the URL of the previous item in the Content Link list file. |
GetPreviousURL (listURL) |
Note: The listURL parameter specifies the location of the content link file; I parameter the index number of item I. |
4, Example 1: In this example, use the Content Link component to add the previous page and next page links to a Web page. (In a linked list [nextlink.txt] file, each line ends with a carriage return, with each item in the row separated by a tab tab.) )
-----------------Nextlink.txt----------------------
One example of 5-02a.asp contentlinking component application
5-02b.asp Content Linking application Example bis
5-02c.asp Content Linking application example three
------------------Nextlink.inc----------------------
<% Set NextLink=Server.CreateObject("MSWC.NextLink") %>
<% if NextLink.GetListIndex ("Nextlink.txt")>1 Then %>
<p>上一页:<A HREF="<%=NextLink.GetPreviousURL("Nextlink.txt") %>"><%=NextLink.GetPreviousDescription("Nextlink.txt") %></A>
<% End if %>
下一页:<A HREF="<%=NextLink.GetNextURL("Nextlink.txt")%>"><%=NextLink.GetNextDescription("Nextlink.txt") %></A>
-------------------5-02a.asp------------------------
<title>Content Linking组件应用示例</title>
<body>
<!-- #include file="nextlink.inc" -->
</body>
-------------------5-02b.asp------------------------
<title>Content Linking组件应用示例</title>
<body>
<!-- #include file="nextlink.inc" -->
</body>
-------------------5-02c.asp------------------------
<title>Content Linking组件应用示例</title>
<body>
<!-- #include file="nextlink.inc" -->
</body>