![]() |
|
|
Published: Wednesday, July 07, 1999 Wouldn't it be nice to have a nifty on-line help system on your website? This help system would need to be fast loading, easy to navigate, pleasing to the eye, and, from an administrative perspective, easy to update. Well, look no further, for I am about to show you how to create a killer help system that's as easy as pie.
First things first, we don't need no stinkin' databases here! We will be using the
In our help system, we will have just one ASP page,
Using the Response Object response.txt Using the Request Object request.txt Impressing your Friends with ASP impress.txt Opening Text Files with ASP textfiles.txt The help index file is broken down into a number of two-lined entries. The first line is the title for the specific help file (i.e. Using the Response Object) and the second line immediately following the title is the name of the file that houses the help itself! For example, here's the contents of response.txt:
<B>The Response Object:</B><BR> The Response Object is ASP's way of communicating with the HTML stream. If you want to send data to the HTML stream, you need to issue a <CODE>Response.Write</CODE> statement, such as: <P><BLOCKQUOTE><CODE> Response.Write "Hello, World!" </CODE></BLOCKQUOTE><P> Pretty easy, eh!?
For each help topic you wanted to have, you would just need to create a text or html file similar to the
one above. Save the file in the same directory as the help.asp and the other help topic files, and, lastly,
add the title/URL to the help index file. Once you've completed those three steps, you're done!!!
It's that easy to add new help topics! If you want to delete a help topic, simply remove its title/URL
from the help index file. To modify an existing help topic, just edit the help topic file (for example,
if we wanted to add more content to the Response help topic, we'd simply edit
<%@ Language=VBScript %>
<% Option Explicit %>
<%
'Expire!!
Response.ExpiresAbsolute = Now() - 1
'The name of our help index file
Const HelpIndex = "helpIndex.txt"
'FSO constants
Const ForReading = 1
'We want to create one instance of a FileSystemObject
Dim fso
Set fso = Server.CreateObject("Scripting.FileSystemObject")
'This will be our file textstream variable
Dim fileTextStream
%>
<HTML>
<BODY>
<TABLE WIDTH=100% BORDER=0 CELLPADDING=3 HEIGHT=100%>
<TR>
<!-- Left column, lists help topics -->
<TD WIDTH=25% VALIGN=TOP BGCOLOR=#CCCCCC>
<FONT FACE=Arial>
<LI><A HREF="help.asp">Help Index</A><BR>
<%
'This will hold the URL and Title
Dim strURL, strTitle
'Make sure the text file exists
If Not fso.FileExists(Server.MapPath(HelpIndex)) then
'Tell the user we can't find the help file...
Response.Write "The help index file could not be located."
else
'Open our help index file and show links to all of our
'help files...
Set fileTextStream = fso.OpenTextFile(Server.MapPath(HelpIndex),ForReading)
While Not fileTextStream.AtEndOfStream
strTitle = fileTextStream.ReadLine
strURL = fileTextStream.ReadLine
Response.Write "<LI><A HREF=""help.asp?" & strURL & """>" & _
strTitle & "</A><BR>" & vbCrLf
Wend
fileTextStream.Close
end if
%>
</FONT>
</TD>
<TD WIDTH=* VALIGN=TOP>
<!-- Show the header you always want to appear, here... -->
<CENTER><FONT SIZE=+2 FACE=Arial><B>
Help System
</B></FONT></CENTER><P>
<FONT FACE=Arial>
<%
'Now, we need to determine what file to load
Dim strFileName
strFileName = Request.QueryString
if Len(strFileName) = 0 then
'No querystring passed in, show default index %>
Welcome to the help system! Choose a topic you want help on
from the list on the left!
<% else
If Not fso.FileExists(Server.MapPath(strFileName)) then
'Tell the user we can't find the help file...
Response.Write "The help file " & strFileName & " could not be located."
else
Set fileTextStream = fso.OpenTextFile(Server.MapPath(strFileName),ForReading)
Response.Write fileTextStream.ReadAll
end if
end if
%>
<!-- Add any standard footer here ... -->
</FONT>
</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<%
'Clean up
Set fileTextStream = Nothing
Set fso = Nothing
%>
Nothing too difficult here. We use the QueryString to determine what help topic the user currently wants to view. We then open the appropriate file and display it! That's all there is to it! You can add a standard header and footer to the help topics by simply adding code where the comments talk about the header and footer. Happy Programming!
Attachments: help.asp
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||