Drew Wutka
DWUTKA at Marlow.com
Fri Dec 14 12:09:03 CST 2007
The following is a plain old .asp file, no VB .dll or anything, that utilizes FP's navigation structure to build a sitemap: <html> <head> <title>Site Map</title> </head> <body> <% '©2003 Drew wutka 'You are free to use this code at any time, just leave the comments in please. 'dwutka at marlow.com dim strFile dim Nodes() dim i dim j strFile=ReadNavigationFile GetRecords Select Case Request.QueryString("View") Case "Indented" DisplayIndentedSiteMap Case "AllBullets" DisplayBulletedSiteMap True Case "ChildBullets" DisplayBulletedSiteMap False Case Else DisplayIndentedSiteMap End Select %> <% Function DisplayBulletedSiteMap(InitialBullet) dim i For i=0 to UBound(Nodes,2) if Nodes(1,i)=0 then If InitialBullet=True Then dim strTemp strTemp=Space(5) response.write "<ul>" & vbcrlf response.write strTemp & "<li>" & vbcrlf response.write strTemp & strTemp & "<a href=""" & Nodes(2,i) & """>" & Nodes(3,i) & "</a>" & vbcrlf BulletChildNodes i,strTemp response.write strtemp & "</li>" & vbcrlf response.write "</ul>" & vbcrlf Else response.write "<a href=""" & Nodes(2,i) & """>" & Nodes(3,i) & "</a>" & vbcrlf BulletChildNodes i,"" response.write "<br>" & vbcrlf end if End if Next End Function Function BulletChildNodes(intArrayPosition,strIndent) dim intID dim i dim strTemp strTemp=strIndent & "<ul>" & vbcrlf intID=Nodes(0,intArrayPosition) For i=0 to UBound(Nodes,2) If Nodes(1,i)=intID Then if strTemp<>"" then response.write strTemp strTemp="" end if response.write strIndent & Space(5) & "<li>" & vbcrlf response.write strIndent & Space(10) & "<a href=""" & Nodes(2,i) & """>" & Nodes(3,i) & "</a>" & vbcrlf response.write strIndent & Space(5) & "</li>" & vbcrlf BulletChildNodes i,strIndent & Space(5) End If Next if strTemp="" then response.write strIndent & "</ul>" & vbcrlf end if End Function Function DisplayIndentedSiteMap dim i For i=0 to UBound(Nodes,2) If Nodes(1,i)=0 then response.write "<a href=""" & Nodes(2,i) & """>" & Nodes(3,i) & "</a><br>" & vbcrlf IndentChildNodes i,"" End if Next End Function Function IndentChildNodes(intArrayPosition,strIndent) dim intID dim i dim strNewIdent strNewIndent=strIndent & "    " intID=Nodes(0,intArrayPosition) For i=0 to UBound(Nodes,2) If Nodes(1,i)=intID Then response.write strNewIndent & "<a href=""" & Nodes(2,i) & """>" & Nodes(3,i) & "</a><br>" & vbcrlf IndentChildNodes i,strNewIndent End If Next End Function Function GetRecords() dim i dim j dim k dim TempRecs dim TempFields TempRecs=Split(strFile,vbcrlf) j=0 For i=0 to Ubound(TempRecs) If InStr(1,TempRecs(i),"\,")>0 then TempRecs(i)=Replace(TempRecs(i),"\,",chr(0) & chr(0)) TempFields=Split(TempRecs(i),",") For k=0 to UBound(TempFields) TempFields(k)=Replace(TempFields(k),chr(0) & chr(0),",") Next else TempFields=Split(TempRecs(i),",") end if If UBound(TempFields)=6 then if j=0 then redim Nodes(3,j) else redim Preserve Nodes(3,j) end if Nodes(0,j)=TempFields(0) Nodes(1,j)=TempFields(4) Nodes(2,j)=TempFields(1) Nodes(3,j)=TempFields(3) j=j+1 end if Next End Function Function ReadNavigationFile() Const ForReading = 1 Dim fso Dim f dim strPath strPath=server.mappath("\_vti_pvt") Set fso = server.CreateObject("Scripting.FileSystemObject") Set f = fso.OpenTextFile(strPath & "\structure.cnf", ForReading) ReadNavigationFile =f.ReadAll set f=nothing set fso=nothing End Function %> </body> </html>