<%
'------------------------------------------------------------------------------
' Alle Rechte vorbehalten.
' Entwickler: Marcus Taegtmeyer
' Firma: Fa. RedDot Solutions AG, Oldenburg, Germany
' Projekt: Navigations
' Modulname: Menu ASP
' Subsystem: RedDot CMS Professional 5.5 or higher
' Copyright (c) RedDot Solutions AG 2004
'------------------------------------------------------------------------------
' Revision: $Revision:$
' $State: $
' $Name: $
'------------------------------------------------------------------------------
' Description: Creates dynamic Navigation
'------------------------------------------------------------------------------
' Disclaimer Dieses Skript ist kein offizieller Bestandteil der RedDot
' Content Management Software. Die RedDot Solutions AG übernimmt
' für dieses Skript keinerlei Gewährleistung und haftet nicht für
' eventuelle durch den Einsatz des Skriptes entstehenden Schäden
' und deren Folgeschäden.
' Das Skript wird nicht von der RedDot Solutions AG supportet.
' Alle Hinweise zu der Funktion des Skripts sind unverbindlich
' und werden nicht von der RedDot Solutions AG garantiert. Alle
' Rechte an diesem Script stehen der RedDot Solutions AG zu.
' Dieses Skript wird kostenlos zur Verfügung gestellt und darf
' nicht weiterverkauft werden
'------------------------------------------------------------------------------
' maximum depth
dim maxdepth
maxdepth = 9
' xml String, that will contain the menu structure
dim xml
' xmlDoc will contain the DOM-Object of xml
dim xmlDoc
' rootNode is the rootNode of the xml
dim rootNode
' success is the flag, that indicates, if the matching ID has been found
dim success
' global path contains a string with each node's content that has been passed to reach the matchig node.
dim global_path
' link will be each item's Properties (linkname|url_of_following_page|page_id_of_following_page)
dim link
' link_string is an array with all links in it
dim link_string
' link_details is an array of each link
dim link_details
' detail is each value of each link
' n and m are counter variables
dim detail, n, m
' my_path(n,0): linkname, my_path(n,1): url_of_following_page, my_path(n,2): ID; limits number of levels to 10
dim my_path(9,2)
' 1. read xml-structure to xml
xml = "" & vbcrlf & "
"
' 2. Load structure into DOM-Object
Set xmlDoc = Server.CreateObject("MSXML.DOMDocument")
XMLDoc.async = False
success = xmlDoc.loadxml(xml)
' 2.a Check for errors!
If Not success Then
Response.Write "Could not load the XML document!"
Else
' 3. Start! Set Root Node to Root of XML
Set rootNode = XMLDoc.documentElement
' 4. Find own ID in xml-tree
call SearchNode(rootNode,1, "")
' 4.a ID found! Global variable global_path now contains path to active link
' 5. Extract path(n,m) from global_path
n=0
m=0
link_string = split(global_path,"||")
for Each link in link_string
link_details = split(link, "|")
For Each detail in link_details
my_path(n,m)=detail
m=m+1
next
m=0
n=n+1
next
' 5.a path to active link now in path(n,m)
' 6. Output the breadcrump-path now!
call OutputPath(rootNode,1)
End If
' Function to find the own Page ID in the xml-tree; writes data into global_path
Function SearchNode(ByVal node, ByVal nDepth, ByVal path)
dim item
' Check, if this is the main menu-item. If not, go on.
if node.nodeName <> "menu" Then
' Save this items values into path.
path = path & node.getAttribute("name") & "|" & node.getAttribute("id") & "|" & node.getAttribute("link") & "||"
' If this node is the one with my id write global_path
if node.getAttribute("id") = my_id then
global_path = path 'found matching link
end if
End if
' If one of this node's children is the one with my id write global_path
For Each item in node.childNodes
if item.nodeName="item" then
if item.getAttribute("id") = my_id and maxdepth > ndepth then 'found active link
global_path = path & item.getAttribute("name") & "|" & item.getAttribute("id") & "|" & item.getAttribute("link") & "||"
exit function
end if
end if
' Look into substructures, call this function again and give it the so far collected path-informations
If item.hasChildNodes() Then
call SearchNode(item,nDepth+1, path) 'recursive call of OutputNode for deeper structure
End If
Next
End Function
' Write Menu Structure for one level
Function OutputLevelOne(ByVal node, ByVal nDepth) 'Write Menu-Entries into page
dim item
dim counter: counter = 0
' Check each child node
For Each item in node.childNodes
if item.nodeName="item" then
' Check, wether this is the first link to be displayed in Level 1
if counter <> 0 then
response.write ""
'response.write " - "
else
counter = 1
end if
' Check, if this link is to be highlighted
'if (item.getAttribute("id") = my_id or item.getAttribute("id") = my_path(nDepth-1,1)) and unescape(item.getAttribute("name")) <> "3" then
if (item.getAttribute("id") = my_id or item.getAttribute("id") = my_path(nDepth-1,1)) and unescape(item.getAttribute("area")) <> "3" and unescape(item.getAttribute("area")) <> "4" and unescape(item.getAttribute("area")) <> "5" and unescape(item.getAttribute("area")) <> "6" then
response.write "
" & unescape(item.getAttribute("name")) & "" & vbcrlf
end if
if (item.getAttribute("id") = my_id or item.getAttribute("id") = my_path(nDepth-1,1)) and (unescape(item.getAttribute("area")) = "3" or unescape(item.getAttribute("area")) = "4" or unescape(item.getAttribute("area")) = "5" or unescape(item.getAttribute("area")) = "6") then 'found active link; use or item.getAttribute("id") = my_path(nDepth-1,1) if whole path should be highlighted
response.write "
" & unescape(item.getAttribute("name")) & "" & vbcrlf
end if
'if (item.getAttribute("id") = my_id or item.getAttribute("id") = my_path(nDepth-1,1)) and my_area = "6" then 'found active link; use or item.getAttribute("id") = my_path(nDepth-1,1) if whole path should be highlighted
'response.write "treffer"
'end if
'response.write my_area
'response.write unescape(item.getAttribute("name"))
'response.write unescape(item.getAttribute("area"))
' mod stop
if item.getAttribute("id") <> my_path(nDepth-1,1) and unescape(item.getAttribute("area")) <> "3" and unescape(item.getAttribute("area")) <> "4" and unescape(item.getAttribute("area")) <> "5" and unescape(item.getAttribute("area")) <> "6" then 'found inactive link
' Write normal link
response.write "
" & unescape(item.getAttribute("name")) & "" & vbcrlf
end if
if item.getAttribute("id") <> my_path(nDepth-1,1) and (unescape(item.getAttribute("area")) = "3" or unescape(item.getAttribute("area")) = "4" or unescape(item.getAttribute("area")) = "5" or unescape(item.getAttribute("area")) = "6") then 'found inactive link
' Write normal link Service
response.write "
" & unescape(item.getAttribute("name")) & "" & vbcrlf
end if
end if
Next
End Function
' 8. Read version
' Function to write the breadcrumbs
Function OutputPath(ByVal node, ByVal nDepth) 'Write Menu-Entries into page
dim item
dim counter
' If this node is the one, with my_id as page_id write it
For Each item in node.childNodes
if item.nodeName="item" then
if item.getAttribute("id") = my_id then 'found active link
response.write ""
'response.write " >>
" & unescape(item.getAttribute("name")) & ""
' Else if this node is part of my path write it
elseif item.hasChildNodes() and item.getAttribute("id") = my_path(nDepth-1,1) and maxdepth > ndepth Then
response.write ""
'response.write " >>
" & unescape(item.getAttribute("name")) & ""
' Check the next level
call OutputPath(item,nDepth+1) 'recursive call of OutputNode for deeper structure
End If
End If
Next
End Function
%>
<%
' 9. Write menu structure
call OutputLevelOne(rootNode,1)
%>
<%
' Write Menu Structure for one level
Function OutputLevel(ByVal node, ByVal nDepth) 'Write Menu-Entries into page
dim item
dim counter
'dim isBinnen
' Check each child node
For Each item in node.childNodes
'if Left(unescape(item.getAttribute("name")),1) = "B" then
'isBinnen = 1
'else
'isBinnen = 0
'end if
'response.write isBinnen
if item.nodeName="item" then
' Check valid levels
if nDepth >= 2 then
response.write "
"
end if
'if nDepth >= 2 and isBinnen = 0 then
if nDepth >= 2 then
' Check, if this link is to be highlighted
if item.getAttribute("id") = my_path(nDepth-1,1)and not item.getAttribute("id") = my_id then 'found active link; use or item.getAttribute("id") = my_path(nDepth-1,1) if whole path should be highlighted
' Write highlighted link path
response.write "" & unescape(item.getAttribute("name")) & ""
end if
if item.getAttribute("id") = my_id then 'found active link; use or item.getAttribute("id") = my_path(nDepth-1,1) if whole path should be highlighted
' Write highlighted link page
response.write "" & unescape(item.getAttribute("name")) & ""
end if
if item.getAttribute("id") = my_id and isBinnen = 1then 'found active link; use or item.getAttribute("id") = my_path(nDepth-1,1) if whole path should be highlighted
' Write highlighted link page
response.write "" & unescape(item.getAttribute("name")) & ""
end if
if not item.getAttribute("id") = my_path(nDepth-1,1) then 'found inactive link
' Write normal link
' use if not item.getAttribute("id") = my_path(nDepth-1,1) then if whole path should be highlighted
response.write "" & unescape(item.getAttribute("name")) & ""
end if
end if
If item.hasChildNodes() and item.getAttribute("id") = my_path(nDepth-1,1) and maxdepth > ndepth Then
' recursive call of OutputNode for deeper structure
'if isBinnen = 0 then
if nDepth = 2 then
response.write ""
else
response.write ""
end if
call OutputLevel(item,nDepth+1)
response.write "
"
End If
'end if
if nDepth >= 2 then
response.write "
"
end if
end if
Next
End Function
' 8. Read version
' 9. Write menu structure
call OutputLevel(rootNode,1)
%>