Using the Content Linker Component
What's the Content Linker Component? It's used to manage large, frequently updated sites which have tutorials, etc. To use the Content Linker Component, you will need a text file to create a linking list file.
| webpageURL description comment |
Each line can contain up to three tab-separated items, like above.
webpageURL is the page you want to link to. Use file names only, URLS that begin with Http:// won't work.
description is a description of the page.
comment is used as a comment for programmers.
So let's create a linking list file:
linkinglistfile.txt
|
tut_fun.asp Functions my functions page
tut_com.asp Components my components page
tut_inc.asp Includes my includes page |
Now we need to create our ASP page that will display our pages from our linking list file.
index.asp
|
<HTML><HEAD>
<TITLE>MY TUTORIALS SECTION</TITLE>
</HEAD><BODY>
Starting ASP<BR>
Welcome to my tutorial selection for programming in asp! Start by clicking on one of the links below...<br>
<%
Dim objLinker
Set ObjLinker = Server.CreateObject("MSWC.NextLink")
Response.Write "<P><A HREF='" & objLinker.GetPreviousURL("linkinglistfile.txt") & "'>" & objLinker.GetPreviousDescription("linkinglistfile.txt") & "</A>" & " " & "<A HREF='" & objLinker.GetNextURL("linkinglistfile.txt") & "'>" & objLinker.GetNextDescription("linkinglistfile.txt") & "</A></P>"
Set objLinker = Nothing
%>
</BODY></HTML> |
The only code we need to review is the following:
|
<%
Dim objLinker
Set ObjLinker = Server.CreateObject("MSWC.NextLink")
Response.Write "<P><A HREF='" & objLinker.GetPreviousURL("linkinglistfile.txt") & "'>" & objLinker.GetPreviousDescription("linkinglistfile.txt") & "</A>" & " " & "<A HREF='" & objLinker.GetNextURL("linkinglistfile.txt") & "'>" & objLinker.GetNextDescription("linkinglistfile.txt") & "</A></P>"
Set objLinker = Nothing
%> |
The code above creates a previous and next link for us. In order for us to accomplish this, we must use the methods GetPreviousURL(), GetPreviousDescription(), GetNextURL() and GetNextDescription() of the NextLink object. They are self explanatory.
Remember to include the code above in all the pages you plan on linking. For instance, tut_fun.asp, tut_com.asp and tut_inc.asp would all have the code above at the bottom of their pages, however, different content.
There are also other methods the NextLink object takes:
GetListCount(listfile) - returns the number of pages the linking list file contains
GetListIndex(listfile) - returns the index number of the current page in linking list file
GetNthURL(listfile, num) - returns the URL of the num page in the linking list file
GetNthDescription(listfile, num) - returns the description of the num page in the linking list file
Using the GetNthURL() and GetNthDescription() methods, we can make a table of contents:
|
<HTML><HEAD>
<TITLE>MY TUTORIALS SECTION</TITLE>
</HEAD><BODY>
Table of Contents<BR>
<%
Dim objLinker, icount, ipage
Set ObjLinker = Server.CreateObject("MSWC.NextLink")
ipages = objLinker.GetListCount("linkinglistfile.txt")
For icount = 1 to ipages
Response.Write "<A HREF='" & objLinker.GetNthURL("linkinglistfile.txt", icount) & "'>" & objLinker.GetNthDescription("linkinglistfile.txt", icount) & "</A><BR>"
Next %> |
The code above will give us a table of contents using a For...Next Loop with a GetNthURL() and GetNthDescription() method.