Using a #include file, the Content Linking component, and IIS 4.0 to create a quick and easy Navigation system for your web.
This demo uses server side #include text file and the Content Linking component. This component is included in the Option pak 4.0 when its installed. This demo will show how to use two text files that resides in your web, one holds the code for the navagation buttons that will be displayed & the necessary ASP code to call the Nextlink method. The 2nd one has a list the pages that you want to be navigated. By the end of this demo I hope you understanding how to use this to create your own quick and easy navigation system using the Content Linking component.
I try to make my demo's original and useful, this idea was discovered when I was reading Wrox Professional ASP Techniques for Webmasters. A plug for Wrox, this book does a good job for me being not so much a newbie anymore but needing how to do more advanced stuff. I thought this was such a cool idea I have to share this on my site. Its an easy concept to grasp-(Or at least I thought so!) that almost anyone could use this. And for those who know me I hate to write lots of code and make things hard. Without further a do the list of things I created for this demo.
#1
A text file created using notepad, it contains the pages you want to be navigated-called contlink.txt. This file contains all the pages listed in order you want them to be displayed & a description. The beauty of this is its very efficient, ie: you want to add file pages and change the order of your site. All you have to change is the text file and the read is automatically changes the rest of the pages already that are created. This is also used by the Table of Contents page to display all possible pages in the web if you want a start page. In this demo its tocexample.asp
Example: Contlink.txt
Page Name: Description of page people will see in the hyperlink
| page1.asp | This is the 1st page of my demo |
| page2.asp | This is the 2nd page of my demo |
| page3.asp | This is the 3rd page of my demo |
#2
A text file created using notepad, it contains the code for the buttons that will be used to navigate-called buttons.inc This file contains all the code needed to process so the navigation button's appear correctly on your site.
#3
Finally all the pages that hold the data you want to display these also can be ASP pages or static html.
Note: On these pages you have to put one line of code to call the #include file. This demo isn't meant make you an expert in #include files but using them is very efficient. Using Server-Side #include files are processed the same time the ASP page is generated. Include files can contain preformatted HTML, asp code or anything else that would normally reside on HTML/ASP pages. This is a handy way of maintaining code in one place and having it used on several pages within your website. For more information on #Include files visit www.activeserverpages.com they have a nice page explaining them.
The code that has to be on the page without server-side code tags <% %> around it.
<!-- #include file="buttons.inc"-->
Code for the Table of Contents page
<html>
<head>
<title>Table of Contents page for Contentlinking demo</title>
</head>
<body>
<h3>Contents List:</h3>
<ul>
'Using the Server.Createobject this is theobject that is created to hold and read the text file that contains
'all the files you want to be displayed in your navigation bars
<%
set Nextlink = Server.Createobject("MSWC.Nextlink")
intCount = Nextlink.GetListCount("contlink.txt")
%>
'Write out the values after the file has been read
<% For intLoop = 1 to intCount %>
<li>
'Uses the GetNthUrl method of the Nextlink object to write out link. Remember in the contlink.txt file you put two 'things, the 'link to the file & the description. The URL gets read into the GetNthRUrl method. The description 'is what the user sees and 'is read into the GetNthDescription method.
<a href="<% = Nextlink.GetNthurl("Contlink.txt", intLoop) %>">
<% = NextLink.GetNthDescription("Contlink.txt", intLoop) %>
</a>
</li>
<% Next %>
</ul>
</body>
</html>
Code for the Contlink.txt file
Link of page Description that the user will see
page1.asp Page One of contentlinking demo
page2.asp Page two of contentlinking demo
page3.asp Page three of contentlinking demo
Code for the buttons.inc file
<b>Method # 1 using buttons</b><br>
<form action="">
<% set objNextLink = server.createobject("mswc.nextlink")
strListFile = "contLink.txt"
intThisPage = objNextLink.GetListIndex(strListFile)
If (intThisPage) > 1 Then %>
<input type="button" onclick="location.href='<% = objNextLink.GetPreviousURL(strListFile) %>';" title="Previous Page" value="Previous">
<% End If %>
<input type="button" onclick="location.href='tocexample.asp';" title="Contents Page" value="Contents">
<% If (intThisPage) < objNextLink.GetListCount(strListFile) Then %>
<input type="button" onclick="location.href='<% = objNextLink.GetNextURL(strListFile) %>';"
title="Next Page" value="Next page">
<% End If %>
</form><br><br>
<b>Method # 2 using numbers on the page</b><br>
<%
set obj2NextLink = server.createobject("mswc.nextlink")
strListFile2 = "contlink.txt"
intThisPage2 = obj2NextLink.GetListIndex(strListFile)
intLastPage2 = obj2NextLink.GetListCount(strListFile)
For intLoop2 = 1 to IntLastPage2
If intThispage2 <> intloop2 Then
response.write "<a href=" & chr(34) _
& obj2nextlink.getNthurl(strListFile2, intLoop2) & chr(34) & ">"
End If
response.write intLoop2
If intThisPage2 <> intLoop2 Then
response.write "</a>"
End if
response.write " "
Next
%>
<a href="tocexample.asp">Content</a>
<br><br>
<%
strListFile3 = "contlink.txt"
set objNextLink3 = server.createobject("mswc.nextlink")
intListCount3 = objnextLink3.GetListCount(strlistfile)
intCurrentPage3 = objNextLink3.GetListIndex(strlistfile)
If intCurrentPage3 > 1 Then
intPrevPage3 = intCurrentPage3 - 1
Else
intPrevPage3 = intListCount3
End If
If intCurrentPage3 < intListCount3 Then
intNextPage3 = intCurrentpage3 + 1
Else
intNextPage3 = 1
End If
%>
<br>
<b>Method # 3 using navigation buttons similiar to the ones used on Microsoft Access forms</b><br>
<form action="">
<input type="button" onclick="location.href='<% = objNextLink3.GetNthURL(strListFile3, 1) %>';"
Title="First Page" value=" |< ">
<input type="button" onclick="location.href='<% = objNextLink3.GetNthURL(strListFile3, intPrevPage3) %>';" Title="Previous Page" value=" < ">
<input type="button" onclick="location.href='tocexample.asp';" title="contents page" value="Contents">
<input type="button" onclick="location.href='<% = objNextLink3.GetNthURL(strListFile3, intNextPage3) %>';" Title="Next Page" value=" > ">
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More ASP Code Articles
More By aspfree
developerWorks - FREE Tools! |
The IBM DB2 Deep Compression ROI tool is designed for DBA’s and IT management personnel to perform a clinical analysis of the cost savings gained from the Storage Optimization feature of DB2 9 for Linux, UNIX and Windows. The feature, also known as Deep Compression, compresses data that lies within a database by up to 80% at times. FREE! Go There Now!
|
|
|
|
As businesses grow increasingly dependent upon Web applications to provide services to customers, employees and partners, these complex applications become more difficult to secure. Although traditional security solutions protect Internet infrastructure layers, they do not guard against HTTP and HTML attacks. Many organizations that conduct security testing still deploy applications that allow attackers to manipulate their logic and wreak havoc on their business. To mitigate this risk, development and delivery teams must address Web application security throughout the lifecycle, addressing the many layers detailed in this paper. FREE! Go There Now!
|
|
|
|
Download the IBM WebSphere Portal V6.1 beta code and learn more about the rich features and enhancements in IBM WebSphere Portal V6.1. WebSphere Portal provides a composite application or business mashup framework and the advanced tooling needed to build flexible, SOA-based solutions, and scalability to meet the needs of any size organization. FREE! Go There Now!
|
|
|
|
Discover how IBM Rational AppScan Standard Edition can help you detext vulnerabilities in your web applications in the Web Application Security eKit. IBM Rational AppScan is a leading suite of automated web application security solutions that scan and test for common Web application vulnerabilities. The new Web Application Security eKit provides you with valuable resources, including white papers, demos, and additional information on the benefits of testing your Web applications. FREE! Go There Now!
|
|
|
|
IBM Enterprise Modernization solutions help organizations evolve core IT systems towards modern architectures and technologies—reducing the burden of maintenance and freeing up resources to develop new business requirements and capabilities. With the IBM Enterprise Modernization Sandbox for System z you can evaluate IBM Enterprise Modernization solutions focused on five key areas: Assets, Architectures, Skills, Processes and Infrastructures, and Investment. Each solution is based upon real customer experiences and offers a proven path to get you started with your modernization projects. FREE! Go There Now!
|
|
|
|
Analysts, architects, and developers who have existing COBOL or PL/I skills and want to extend those skills to deploy new workloads on the mainframe can use the IBM Enterprise Modernization Sandbox for System z to find hands-on walkthroughs of common real world scenarios. The scenarios provide examples of how to rapidly design, create, assemble, test, and deploy high-quality Web, Web services, portal, and SOA applications for IBM CICS, IBM IMS, and IBM WebSphere Application Server. FREE! Go There Now!
|
|
|
|
As systems increase in complexity, communication between systems and software teams becomes more and more difficult. Now, there’s a way to improve product quality and communication.<br />Read the “Model Driven Systems Development” white paper to see how. Also included in this kit are more educational white papers, customer examples, tutorials, informative Webcasts, and best practices for designing, building and managing systems.<br /> FREE! Go There Now!
|
|
|
|
Learn how to implement a build management system that uses and extends your existing automation technologies. This tutorial shows, step-by-step, how to install and configure IBM Rational Build Forge to manage builds for Jakarta Tomcat from source code. FREE! Go There Now!
|
|
|
|
XML has become a common way of storing business data as flat files and many data server vendors including IBM have provided ways to store this data within relational database systems. Increasingly collections of XML files are accessed like databases using an xQuery and other XML standard mechanisms. Businesses find the need to combine the traditional tabular structured data with XML formatted data. In this webcast, you’ll learn about IBM’s WebSphere Federation Server technology, which provides users with the ability to integrate these two data formats. FREE! Go There Now!
|
|
|
|
Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |