ASP Content Linkingコンポーネント


Examples

試してみる - サンプル

Content Linking コンポーネント
この例では、コンテンツリストを構築します。

Content Linking コンポーネント 2
この例では、Content Linking コンポーネントを使用して、テキストファイルにリストされているページ間をナビゲートします。


ASP Content Linking コンポーネント

ASP Content Linking コンポーネントは、迅速かつ便利なナビゲーションシステムを作成するために使用されます!

Content Linking コンポーネントは Nextlink オブジェクトを返します。このオブジェクトは、ナビゲートする必要がある Web ページのリストを保持するために使用されます。

構文

<%
Set nl=Server.CreateObject("MSWC.NextLink")
%>


ASP Content Linking サンプル

まず、テキストファイル "links.txt" を作成します。

asp_intro.asp ASP 入門
asp_syntax.asp ASP 構文
asp_variables.asp ASP 変数
asp_procedures.asp ASP プロシージャ

上記のテキストファイルには、ナビゲートする必要があるページが含まれています。ページの並び順は表示順と同じである必要があり、各ファイル名の説明が含まれます(タブを使用してファイル名と説明情報を区切ります)。

注:リストにページを追加したり、リスト内のページの順序を変更したりしたい場合は、このテキストファイルを変更するだけで済みます!ナビゲーションは自動的に更新されます!

次に、参照ファイル "nlcode.inc" を作成します。.inc ファイルは "links.txt" にリストされているページ間をナビゲートするための NextLink オブジェクトを作成します。

"nlcode.inc":

<%
dim nl
Set nl=Server.CreateObject("MSWC.NextLink")
if (nl.GetListIndex("links.txt")>1) then
Response.Write("<a href='" & nl.GetPreviousURL("links.txt"))
Response.Write("'>Previous Page</a>")
end if
Response.Write("<a href='" & nl.GetNextURL("links.txt"))
Response.Write("'>Next Page</a>")
%>

テキストファイル "links.txt" にリストされている各 .asp ページに、次のコード行を配置してください:<!-- #include file="nlcode.inc"-->。このコード行により、"links.txt" にリストされている各ページで "nlcode.inc" 内のコードが参照され、ナビゲーションが機能するようになります。


ASP Content Linking コンポーネントのメソッド

メソッド 説明 サンプル
GetListCount コンテンツリンクリストファイルにリストされている項目の数を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetListCount("links.txt")
Response.Write("There are ")
Response.Write(c)
Response.Write(" items in the list")
%>

出力:

There are 4 items in the list

GetListIndex コンテンツリンクリストファイル内の現在のエントリのインデックス番号を返します。最初のエントリのインデックス番号は 1 です。現在のページがコンテンツリンクリストファイルにない場合は 0 を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetListIndex("links.txt")
Response.Write("Item number ")
Response.Write(c)
%>

出力:

Item number 3

GetNextDescription コンテンツリンクリストファイルにリストされている次のエントリのテキスト説明を返します。現在のファイルがリストファイルに見つからない場合は、リスト内の最後のページのテキスト説明を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNextDescription("links.txt")
Response.Write("Next ")
Response.Write("description is: ")
Response.Write(c)
%>

出力:

Next description is: ASP Variables

GetNextURL コンテンツリンクリストファイルにリストされている次のエントリの URL を返します。現在のファイルがリストファイルに見つからない場合は、リスト内の最後のページの URL を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNextURL("links.txt")
Response.Write("Next ")
Response.Write("URL is: ")
Response.Write(c)
%>

出力:

Next URL is: asp_variables.asp

GetNthDescription コンテンツリンクリストファイルにリストされている N 番目のページの説明情報を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNthDescription("links.txt",3)
Response.Write("Third ")
Response.Write("description is: ")
Response.Write(c)
%>

出力:

Third description is: ASP Variables

GetNthURL コンテンツリンクリストファイルにリストされている N 番目のページの URL を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetNthURL("links.txt",3)
Response.Write("Third ")
Response.Write("URL is: ")
Response.Write(c)
%>

出力:

Third URL is: asp_variables.asp

GetPreviousDescription コンテンツリンクリストファイルにリストされている前のエントリのテキスト説明を返します。現在のファイルがリストファイルに見つからない場合は、リスト内の最初のページのテキスト説明を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetPreviousDescription("links.txt")
Response.Write("Previous ")
Response.Write("description is: ")
Response.Write(c)
%>

出力:

Previous description is: ASP Variables

GetPreviousURL コンテンツリンクリストファイルにリストされている前のエントリの URL を返します。現在のファイルがリストファイルに見つからない場合は、リスト内の最初のページの URL を返します。 <%
dim nl,c
Set nl=Server.CreateObject("MSWC.NextLink")
c=nl.GetPreviousURL("links.txt")
Response.Write("Previous ")
Response.Write("URL is: ")
Response.Write(c)
%>

出力:

Previous URL is: asp_variables.asp


その他の拡張