<% Response.Expires = 2 Server.ScriptTimeout = 10000 set con = server.createobject("ADODB.Connection") con.open Application("CString") con.CommandTimeout = 1000 i_MenuSectionID = 1 Session("b_Auxiliary") = 1 Session("MenuSectionID") = 1 i_MenuLevels = 2 i_MenuOptions = NULL Sub MaxLevels(intMenuID, intMaxCount, intLevel) if intMenuID = 0 then strSQL = "SELECT MenuID FROM CMS_Menu WHERE MenuSectionID = "& Session("MenuSectionID") &" AND MainMenuID IS NULL" else strSQL = "SELECT MenuID FROM CMS_Menu WHERE MenuSectionID = "& Session("MenuSectionID") &" AND MainMenuID = "& intMenuID end if set rsMenuCount = con.execute(strSQL) if not rsMenuCount.EOF then do while not rsMenuCount.EOF MaxLevels rsMenuCount("MenuID"), intMaxCount, intLevel + 1 rsMenuCount.MoveNext loop end if set rsMenuCount = Nothing if intLevel > intMaxCount then intMaxCount = intLevel end if End Sub Sub GetSubs(intMenuID, strMainOption, intLevel) if intLevel < i_MenuLevels or IsNull(i_MenuLevels) then strSQL = "SELECT MenuID, MenuName, MenuOrder FROM CMS_Menu WHERE MenuSectionID = "& Session("MenuSectionID") &" AND MainMenuID = "& intMenuID &" ORDER BY MenuOrder" set rsSubMenus = con.execute(strSQL) do while not rsSubMenus.EOF i_MenuID = rsSubMenus("MenuID") s_MenuName = rsSubMenus("MenuName") Response.Write("" & VBCrLf) GetSubs i_MenuID, strMainOption &" \ "& s_MenuName, intLevel + 1 rsSubMenus.MoveNext loop set rsSubMenus = Nothing end if End Sub Sub DeleteSubs(intMenuID) strSQL = "SELECT MenuID FROM CMS_Menu WHERE MainMenuID = "& intMenuID set rsSubMenus = con.execute(strSQL) if not rsSubMenus.EOF then do while not rsSubMenus.EOF DeleteSubs rsSubMenus("MenuID") rsSubMenus.MoveNext() loop strSQL = "DELETE FROM CMS_Menu WHERE MainMenuID = "& intMenuID con.execute(strSQL) end if set rsSubMenus = Nothing End Sub Function GetMenuLine(intID) strSQL = "SELECT MainMenuID, MenuName FROM CMS_Menu WHERE MenuID = "& intID set rsMenu = con.execute(strSQL) if not rsMenu.EOF then rsMenu.MoveFirst() i_tmpMainMenuID = rsMenu("MainMenuID") s_tmpMenuName = rsMenu("MenuName") if Not IsNull(i_tmpMainMenuID) then GetMenuLine = GetMenuLine & GetMenuLine(i_tmpMainMenuID) end if GetMenuLine = GetMenuLine & s_tmpMenuName & " \ " end if set rsMenu = Nothing End Function strSQL = "(SELECT *, 1 AS 'Subs' "&_ "FROM CMS_Menu "&_ "WHERE MenuSectionID = "& i_MenuSectionID &" AND MainMenuID IS NULL AND "&_ "MenuID IN (SELECT DISTINCT MainMenuID "&_ " FROM CMS_Menu "&_ " WHERE MenuSectionID = "& i_MenuSectionID &" AND MainMenuID IS NOT NULL)) "&_ "UNION "&_ "(SELECT *, 0 AS 'Subs' "&_ "FROM CMS_Menu "&_ "WHERE MenuSectionID = "& i_MenuSectionID &" AND MainMenuID IS NULL AND "&_ "MenuID NOT IN (SELECT DISTINCT MainMenuID "&_ " FROM CMS_Menu "&_ " WHERE MenuSectionID = "& i_MenuSectionID &" AND MainMenuID IS NOT NULL)) "&_ "ORDER BY MenuOrder" set rsMenu = con.execute(strSQL) s_Heading = "Sitemap" %> <%=Server.HTMLEncode(s_Heading)%> :. P.K. Ferraris & Associates - Financial Planning South Africa <%if rsMenu.EOF then else intMaxCount = 0 MaxLevels 0, intMaxCount, 0 %> <% Sub GetSubMenus(intMenuID, intLevel, intCounterx, bRSEnd) strSQL = "(SELECT *, 1 AS 'Subs' "&_ "FROM CMS_Menu "&_ "WHERE MenuSectionID = "& Session("MenuSectionID") &" AND MainMenuID = "& intMenuID &" AND "&_ "MenuID IN (SELECT DISTINCT MainMenuID "&_ " FROM CMS_Menu "&_ " WHERE MenuSectionID = "& Session("MenuSectionID") &" AND MainMenuID IS NOT NULL)) "&_ "UNION "&_ "(SELECT *, 0 AS 'Subs' "&_ "FROM CMS_Menu "&_ "WHERE MenuSectionID = "& Session("MenuSectionID") &" AND MainMenuID = "& intMenuID &" AND "&_ "MenuID NOT IN (SELECT DISTINCT MainMenuID "&_ " FROM CMS_Menu "&_ " WHERE MenuSectionID = "& Session("MenuSectionID") &" AND MainMenuID IS NOT NULL)) "&_ "ORDER BY MenuOrder" set rsSubMenu = con.execute(strSQL) i_SubLoopCounter = 0 do while not rsSubMenu.EOF i_MenuID = rsSubMenu("MenuID") i_MenuSectionID = rsSubMenu("MenuSectionID") s_MenuName = rsSubMenu("MenuName") i_MenuOrder = rsSubMenu("MenuOrder") i_MainMenuID = rsSubMenu("MainMenuID") i_PageID = rsSubMenu("PageID") s_Frame = rsSubMenu("Frame") b_Subs = rsSubMenu("Subs") %> <%if CInt(b_Subs) = 1 then GetSubMenus i_MenuID, intLevel + 1, counterx, rsSubMenu.EOF%> <%i_SubLoopCounter = i_SubLoopCounter + 1%> <%loop End Sub %> <% counterx=0 i_MainLoopCounter = 0 do while not rsMenu.EOF i_MenuID = rsMenu("MenuID") i_MenuSectionID = rsMenu("MenuSectionID") s_MenuName = rsMenu("MenuName") i_MenuOrder = rsMenu("MenuOrder") i_MainMenuID = rsMenu("MainMenuID") i_PageID = rsMenu("PageID") s_Frame = rsMenu("Frame") b_Subs = rsMenu("Subs") b_ShowIcons = true b_ShowIconsTop = true %> <%if CInt(b_Subs) = 1 then GetSubMenus i_MenuID, 0, counterx, rsMenu.EOF%> <%i_MainLoopCounter = i_MainLoopCounter + 1%> <%loop%> <%end if%>

Menu

<%if Not bRSEnd then%> <%else%> <%end if%> <%For y = 1 to intLevel%> <%if Not bRSEnd then%> <%else%> <%end if%> <%Next%> <%rsSubMenu.movenext%> <%if rsSubMenu.EOF then%> <%else%> <%end if%> <%if CInt(b_Subs) = 1 then%> <%else%> <%end if%> <% if ISNull(i_PageID) then %> <%=s_MenuName%> <% else %> <%=s_MenuName%> <% end if %>

<%rsMenu.movenext%> <%if rsMenu.EOF then%> <%else%> <%end if%> <%if CInt(b_Subs) = 1 then%> <%else%> <%end if%> <% if ISNull(i_PageID) then %> <%=s_MenuName%> <% else %> <%=s_MenuName%> <% end if %>