![]() |
|
|
Published: Wednesday, November 04, 1998
When users browse your web site, there is the a tendency to get lost in all of
the information present. This poses a larger problem when get past a few
dozen pages. As pretty much all really good sites have lots of content, it's
important to make navigation as easy as possible; lest the users get fed up
with your site because they are constantly lost!
So, Microsoft, in their infinite wisdom, provided the Content Linking component. While this is a good tool for making web pages act like book pages, it really doesn't address following where the users are/have been. Also, it's not terribly dynamic. You, the web site developer, have to pre-define the order of the pages, how they should be listed, and fix their URLs... Not particularly nice if you move things around much, since you have to fix the linking file every time you do it. Then Microsoft, in their FrontPage product, allowed you to create dynamic navigation bars. This was a lot better concept, but it has a few flaws. Unless you want to waste a bunch of space on your pages displaying the navigation text/icons/buttons there isn't much of a choice. Also, the editor for the relationships doesn't track with the links for the documents. So, once again, every time you move things around you also need to move them in the Navigation Bar view to match. You will probably be more than slightly happy to know that there is a solution to this annoyance. Better yet, it's completely coded in VBScript running under ASP! Not only does this mean that it's a cinch to set up, but it's also completely customizable. So, without further ado, let's dive in and have a look at what's involved.
Step 1: Install the
Step 2: Install and customize the HISTMAINT.INC and HISTSHOW.INC files.
These are the include files which make all of the magic happen. We'll discuss
what's inside
<%
'HistShow.inc - Show the entries in the History List
'***************************************************************
'NOTE: This module should be modified to format the result
' data in the necessary fashion to be properly displayed on
' *your pages*! Remember to handle any additional ThisXXX
' entries here, or things will get really ugly!
dim HistArray
dim HistURL, HistText
'Dim any additional data entries for ThisXXX as HistXXX here!
HistArray = Session("HistLog").Items
HistPtr = Session("HistCount")
Response.Write("History Counter is " & HistPtr & "<br>")
for i = 0 to HistPtr - 1 step ItemCount
HistURL = HistArray(i)
HistText = HistArray(i + 1)
'Restore any additional ThisXXX entries as HistXXX here!
'Example line below is for each ThisXXX entry
' note the index change!)
'HistXXX = HistArray(i + 2)
Response.Write(HistText & " at URL <a href=""" & _
HistURL & """>" & HistURL & "</a><br>")
next
%>
The first
Think about what you want to make the Content List look like, try making a
static version of it in your HTML editor, then substitute
Remember that if you're adding more than one extra item, you'll need to increment the value added to i for each one. That's all there is to be done inside HISTSHOW.INC. I'm sure you've had worse tasks to do!
Step 3: Update your ASP pages to use
<%
Dim ThisURL, ThisText
'Dim any additional data entries for ThisXXX here!
ThisURL = "http://" & Request.ServerVariables("SERVER_NAME") & _
Request.ServerVariables("PATH_INFO")
ThisText = "Start Page"
'Set any additional data entries for ThisXXX here!
%>
<!-- #include virtual="/{your include path}/HistMaint.inc" -->
The DIM statement is used to define the variables that we will be providing
to After that, we need the include tag to make the magic happen. Obviously, the {your include path} should be replaced with wherever you place the include files on your server.
That covers maintenance of
Yes... you have to fix the {your include path} here aswell. If you are going to use plain text for your output, that's all the editing that each of your ASP pages requires. Simple? You bet!
Perhaps we should look into how We start by determining if the list is empty. Oh dear! When a user first accesses a page with this code, the list will be empty. It's a perfectly normal condition to have. In this case, we simply insert ourselves as the first entry in the list, and that's that. If there are already entries in the list, then we need to dig a little deeper. Next, we check to see if we're already at the end of the list. If we are, we probably shouldn't add ourselves again. It would be bad for the same page to be listed more than once to the user! Now that we've determined we're not the last entry in the list, we need to do something really tricky. We'll search the list to see if we're in there. Let's assume that we're already in the list at some point. If the user wants to go there, we shouldn't show them the entries that follow, so we'll need to flush the rest of the list. It's of no use to us, so wave it goodbye! Now that the list ends with us, we don't need to add ourselves again, so we're done. If we've found that there was nothing to flush (we weren't in the list), then we need to add ourselves to the end of the list. In doing so, we've completed our task of maintenance, and should allow the page to be displayed.
Customization of
The two here is indicative of
Both places use the same code, so there is no confusion as to which is which.
As far as basic customization of Well, sadly that's all there is to be said and done. Now it's time for you to go off and implement this tool on your own web sites. Happy Programming! Attachments:
Bart Silverstein has written several great articles for 4GuysFromRolla.com. When he is not writing articles, Bart is often found on the many ASP messageboards, answering questions.
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
![]() |
![]() |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||