Part IV: Linking the Content

Now that you have the home page started and the style sheet defined, you are ready to use the Content Linking component to create the magazine. The Content Linking component relies on a text file that describes the Web pages contained in the online publication. These pages can be hard-coded HTML documents that you want to link together, or they can be ASP pages that generate your content dynamically. In this project, you will use the Magazine data source to generate ASP pages for your magazine content. The data source uses query string arguments to specify which article will be displayed.

Step 1

If you don't already have the Magazine project open, open it. Choose New from the File menu. In the New dialog box, add a text file and name the file MAGAZINE.TXT. This is the content linking text file, and the entries in the file are the Uniform Resource Locators (URLs) of the pages you want linked. In this project, the URL will always be the same (since content is generated by ASP), but you will pass different arguments to designate the articles. Add the following entries to MAGAZINE.TXT to set up the links:

/Magazine/Content.asp?ArticleID=1    Create ActiveX Controls /Magazine/Content.asp?ArticleID=2    Developer Days Information /Magazine/Content.asp?ArticleID=3    CTVBSIG Information 

Save MAGAZINE.TXT, and return to DEFAULT.ASP.

Step 2

You need to produce a table of contents for the magazine. This table will appear on the home page and will be generated using the content linking text file. The Content Linking component gives you several methods for returning the contents of the text file, enabling you to find out how many entries are in the file and to access them one at a time. When you read each item, you will dynamically generate a hyperlink to the appropriate document and display the hyperlink in a table. Add the following code to the BODY section of DEFAULT.ASP, just below the <HR> tag you inserted earlier:

<% ` Variables Dim objLinker Dim i ` Create Content Linking component Set objLinker = Server.CreateObject("MSWC.NextLink") %> <!-- Generate table of contents from Content Linking list --> <H1>Table of Contents</H1> <TABLE> <% For i = 1 to objLinker.GetListCount("Magazine.txt") %>     <TR>         <TD><IMG SRC="/Chapter8/Images/Bullet.gif"></TD>         <TD><H3><A HREF="<%=objLinker.GetNthURL("Magazine.txt", i)%>">         <%=objLinker.GetNthDescription("Magazine.txt", i)%></A></H3>         </TD>     </TR> <%Next%> </TABLE> 

Step 3

Save your work, and preview DEFAULT.ASP in Internet Explorer by selecting Browse With from the File menu. In the Browse With dialog box, choose Internet Explorer. You should see the table of contents displayed on the home page, as shown in Figure 8-5.

Figure 8-5. The magazine cover page.



Programming Active Server Pages
Programming Active Server Pages (Microsoft Programming Series)
ISBN: 1572317000
EAN: 2147483647
Year: 1996
Pages: 84

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net