<% 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) 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 Sub Function GetSubs2(intMenuID, strMainOption, intLevel, strExcludeMenuIDs) strSQL = "SELECT MenuID, MenuName, MenuOrder " & _ "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)" strSQL = "SELECT MenuID, MenuName, MenuOrder " & _ "FROM CMS_Menu " & _ "WHERE MenuSectionID = " & Session("MenuSectionID") & " AND " & _ "MainMenuID = " & intMenuID & " AND " & _ "PageID IS NULL " if strExcludeMenuIDs <> "" then strSQL = strSQL & " AND MenuID NOT IN (" & strExcludeMenuIDs & ") " end if strSQL = strSQL & "ORDER BY MenuOrder" 'strExcludeMenuIDs set rsSubMenus = con.execute(strSQL) strResults = "" do while not rsSubMenus.EOF i_MenuID = rsSubMenus("MenuID") s_MenuName = rsSubMenus("MenuName") strResults = strResults & i_MenuID & "||" & strMainOption &" \ "& s_MenuName & vbCrLf strResults = strResults & GetSubs2(i_MenuID, strMainOption &" \ "& s_MenuName, intLevel + 1, strExcludeMenuIDs) rsSubMenus.MoveNext loop set rsSubMenus = Nothing GetSubs2 = strResults End Function 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 %>