The content linker Component
The Content linker is a tool which enables the
web developer to produce an easy to use (navigate) web site by providing
index pages and next /previous navigation buttons.
Structure of the Content linker
The Content Linker is a tool enables the web developer to produce
an easy to use (navigate) web site by providing index pages and next/previous
navigation buttons.
The Index file for Content Linker
The index file used by content linker is a text file of list of
.asp pages, in the order that they should be displayed. If you want
to change the order just by rearranging them in the content linker
index file.
The index file contains one line of text for each page. Each line
consists of the URL, description and optional comment, delimited
by Tab characters(not spaces!)
For example:
hat501.asp This Week's Hat Run 4/25/2002
sweater.asp This week's sweater 4/26/2000
kidslovepc.asp ASP tutorial
The Content Linker Component methods:
GetListCount(index_file): Returns the number of files in index_file
GetListIndex(index_file): Returns the index number of the current
page in the file index_file
GetNextURL(index_file): Returns the URL of the next page in the index_file
GetNextDescription(index_file): Returns the description of the next
page in file index_file
GetPreviousURL(index_file): Returns the URL of the previous page
in the file index_file
GetPreviousDescription(index_file): Returns the description of the
previous page in file index_file.
GetNthURL(index_file,n): Returns the URL of the nth page in the file
index_file
GetNthDescription(index_file,n): Return the description of the nth
page in the file index_file.
ASP pages in index file
Each ASP pages in index file contains two parts. The first part
consists of the normal content, the second part is the ASP code that
uses the content linker to navigate.
Example :
<html>
<body>
Hat of the week
Harray Potter
<%
Dim MyPageNext
Dim objNL
Set objNL=Server.CreateObject("MSWC.NextLink")
MyPageNext=objNL.GetNextURL("index.txt")
%>
Click <a Href=<%=MyPageNext%>> Here for the next</a>
</body>
</html>
Problem--What happens when we want to add new pages or delete existing
pages? If they are at the beginning or end, we need to adjust our
naviagtion for those pages.
Solution: Change the navigation code so that it will work regardless
of location within the index file.
Example:
<html>
<body>
Hat of the week
Harray Potter
<%
Dim MyPageNext
Dim MyDescriptNext
Dim MyPagePrev
Dim MyDescritpPRev
Dim objNL
Dim MyListIndex
Dim MyListCount
Set objNL=Server.CreateObject("MSWC.NextLink")
MyPagePrev=objNL.GetPreviousURL("index.txt")
MyDescritpPRev=objNL.GetPreviousDescription("index.txt")
MyPageNext=objNL.GetNextURL("index.txt")
MyDescriptNext=objNL.getNextDescription("index.txt")
myListIndex=objNL.GetListIndex("index.txt")
myListCount=objNL.GetListCount("index.txt")
%>
<% if myListIndex>1 then%>
Click <a href=<%=MypagePrev%>> here</a> to move
back to <%=myDescriptPrev%>
<%End if%>
<br>
<% if myListIndex<> myListCount then %>
Click <a href=<%=MyPageNext%>>here </a> to move
next to<%=MyDescriptNext%>
<%end if%>
</body>
</html>
Problem --We want to add Home and End links, not hard coded into
the HTML but driven from the Index file.
Solution: Home will be the first entry in the index file and End
will be the last Entry. Utilize the GetNextURL method with a position
parameter.
<html>
<body>
Hat of the week
Harray Potter
<%
Dim MyPageNext
Dim MyDescriptNext
Dim MyPagePrev
Dim MyDescritpPRev
Dim MyListIndex
Dim MyListCount
Dim objNL
Dim MyFirstPage
Dim MyEndPage
Set objNL=Server.CreateObject("MSWC.NextLink")
MyPagePrev=objNL.GetPreviousURL("index.txt")
MyDescritpPRev=objNL.GetPreviousDescription("index.txt")
MyPageNext=objNL.GetNextURL("index.txt")
MyDescriptNext=objNL.getNextDescription("index.txt")
myListIndex=objNL.GetListIndex("index.txt")
MyListCount=objNL.GetListCount("index.txt")
MyFirstPage=objNL.GetNthURL("index.txt",1)
MyEndPage = objNL.GetNthURL("index.txt",MyListCount)
%>
<% if myListIndex>1 then%>
Click <a href=<%=MypagePrev%>> here</a> to move
back to <%=myDescriptPrev%>
<%End if%>
<br>
<% if myListIndex<> myListCount then %>
Click <a href=<%=MyPageNext%>>here </a> to move
next to<%=MyDescriptNext%>
<%end if%>
<br>
Click <a href=<%=MyFirstPage%>>here to go home page</a><br>
Click <a href=<%=MyEndPage%> > here to go Last page </a>
</body>
</html>
|