I've written a subroutine for generating the tree navigation list shown on most pages in the forums.
Advantages of using this code are:
* If any changes to the style of the tree were required then it would only need changing in one location.
* Easier to create trees in new pages.
'Subroutine to show the branches of the navigation tree
Sub ShowTreeBranch (pintLevel, pstrIcon, pstrDescription, pstrURL)
Response.Write "<font face=""" & strDefaultFontFace & """ size=""" & strDefaultFontSize & """>"
If pintLevel = 0 then
Response.Write getCurrentIcon(strIconFolderOpen,"","align=""absmiddle""") & " <a href=""default.asp"">All Forums</a>"
else
for iLoop = 2 to pintLevel
Response.Write "" & getCurrentIcon(strIconBlank,"","align=""absmiddle""")
next
Response.Write "" & getCurrentIcon(strIconBar,"","align=""absmiddle""")
if pstrIcon <> "" then
Response.Write getCurrentIcon(pstrIcon,"","align=""absmiddle""")
else
Response.Write getCurrentIcon(strIconFolderOpen,"","align=""absmiddle""")
end if
if pstrURL <> "" then
Response.Write " <a href=""" & pstrURL & """>" & pstrDescription & "</a>"
else
Response.Write " " & pstrDescription
end if
end if
Response.Write "</font><br />" & vbNewLine
End Sub
For example, the code to generate the tree in topic.asp would then look like:
Response.Write " <table border=""0"" width=""100%"">" & vbNewLine & _
" <tr>" & vbNewLine & _
" <td width=""50%"" align=""left"" nowrap>" & vbNewLine
ShowTreeBranch 0, "", "", ""
if Cat_Status <> 0 then
strTreeIcon = strIconFolderOpen
else
strTreeIcon = strIconFolderClosed
end if
ShowTreeBranch 1, strTreeIcon, ChkString(Cat_Name,"display"), "default.asp?CAT_ID=" & Cat_ID
if ArchiveView = "true" then
strTreeIcon = strIconFolderArchived
else
if Forum_Status <> 0 and Cat_Status <> 0 then
strTreeIcon = strIconFolderOpen
else
strTreeIcon = strIconFolderClosed
end if
end if
ShowTreeBranch 2, strTreeIcon, ChkString(Forum_Subject,"display"), "forum.asp?" & ArchiveLink & "FORUM_ID=" & Forum_ID
if Request.QueryString("SearchTerms") <> "" then
strTreeText = SearchHiLite(ChkString(Topic_Subject,"title"))
else
strTreeText = ChkString(Topic_Subject,"title")
end if
if ArchiveView = "true" then
strTreeIcon = strIconFolderArchived
elseif Cat_Status <> 0 and Forum_Status <> 0 and Topic_Status <> 0 then
strTreeIcon = strIconFolderOpenTopic
else
strTreeIcon = strIconFolderClosedTopic
end if
ShowTreeBranch 3, strTreeIcon, strTreeText, ""
Response.Write "</td>" & vbNewLine