ArtMenuSO - ShowOnlyCurrent |
|
HannesS
|
Hi,
how can I limit the menu on a Submenuitem?
In DNN menu that goes with ShowOnlyCurrent.
Thx,
Hannes
|
|
HannesS
|
Ok, here is the Answer:
Only Artitsteer 2.3!
Search the Install:
C:\Programme\Artisteer 2\Library\Data\Templates\DotNetNuke\Export\Files\Common\Menu
Open the File: ArtMenuSO.ascx.vb and delete the Code
Inside this Code:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Common.Globals
Imports DotNetNuke.Services.Exceptions.Exceptions
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.Security
Imports System.Text
Namespace ArtMenuSkinObject
Partial Public Class ArtMenuSO
Inherits DotNetNuke.UI.Skins.SkinObjectBase
Private _showHiddenTabs As Boolean = False
Private _showDeletedTabs As Boolean = False
Private _showAdminTabs As Boolean = True
Private _showLoginTab As Boolean = True
Private _showUserTab As Boolean = True
Private _ShowOnlyCurrent As String = String.Empty
Public Property ShowOnlyCurrent() As String
Get
Return _ShowOnlyCurrent
End Get
Set(ByVal value As String)
_ShowOnlyCurrent = value
End Set
End Property
Public Property ShowHiddenTabs() As String
Get
Return _showHiddenTabs.ToString()
End Get
Set(ByVal value As String)
If Not (String.IsNullOrEmpty(value)) Then
_showHiddenTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowDeletedTabs() As String
Get
Return _showDeletedTabs.ToString()
End Get
Set(ByVal value As String)
If Not (String.IsNullOrEmpty(value)) Then
_showDeletedTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowAdminTabs() As Boolean
Get
Return _showAdminTabs.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showAdminTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowLoginTab() As Boolean
Get
Return _showLoginTab.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showLoginTab = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowUserTab() As Boolean
Get
Return _showUserTab.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showUserTab = Boolean.Parse(value)
End If
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Me.litMenuHtml.Text = GetMenuHtml()
If Me.ShowLoginTab Or Me.ShowUserTab Then
Me.litMenuHtmlTail.Text = "</li>"
End If
If Me.ShowLoginTab And Me.ShowUserTab Then
Me.litMenuTokensSeparator.Visible = True
Me.litMenuTokensSeparator.Text = "</li><li>"
End If
Me.litMenuHtmlTail.Text &= "</ul></div></div>"
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Sub
Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
Try
If Not Me.ShowLoginTab Then
Me.dnnLogin.Visible = False
Else
Dim cmdLogin As LinkButton = CType(Me.dnnLogin.FindControl("cmdLogin"), LinkButton)
cmdLogin.Text = String.Format("<span class=""l""></span><span class=""r""></span><span class=""t"">Ok, here is the Answer:
Only Artitsteer 2.3!
Search the Install:
C:\Programme\Artisteer 2\Library\Data\Templates\DotNetNuke\Export\Files\Common\Menu
Open the File: ArtMenuSO.ascx.vb and delete the Code
Inside this Code:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Common.Globals
Imports DotNetNuke.Services.Exceptions.Exceptions
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.Security
Imports System.Text
Namespace ArtMenuSkinObject
Partial Public Class ArtMenuSO
Inherits DotNetNuke.UI.Skins.SkinObjectBase
Private _showHiddenTabs As Boolean = False
Private _showDeletedTabs As Boolean = False
Private _showAdminTabs As Boolean = True
Private _showLoginTab As Boolean = True
Private _showUserTab As Boolean = True
Private _ShowOnlyCurrent As String = String.Empty
Public Property ShowOnlyCurrent() As String
Get
Return _ShowOnlyCurrent
End Get
Set(ByVal value As String)
_ShowOnlyCurrent = value
End Set
End Property
Public Property ShowHiddenTabs() As String
Get
Return _showHiddenTabs.ToString()
End Get
Set(ByVal value As String)
If Not (String.IsNullOrEmpty(value)) Then
_showHiddenTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowDeletedTabs() As String
Get
Return _showDeletedTabs.ToString()
End Get
Set(ByVal value As String)
If Not (String.IsNullOrEmpty(value)) Then
_showDeletedTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowAdminTabs() As Boolean
Get
Return _showAdminTabs.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showAdminTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowLoginTab() As Boolean
Get
Return _showLoginTab.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showLoginTab = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowUserTab() As Boolean
Get
Return _showUserTab.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showUserTab = Boolean.Parse(value)
End If
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Me.litMenuHtml.Text = GetMenuHtml()
If Me.ShowLoginTab Or Me.ShowUserTab Then
Me.litMenuHtmlTail.Text = ""
End If
If Me.ShowLoginTab And Me.ShowUserTab Then
Me.litMenuTokensSeparator.Visible = True
Me.litMenuTokensSeparator.Text = ""
End If
Me.litMenuHtmlTail.Text &= ""
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Sub
Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
Try
If Not Me.ShowLoginTab Then
Me.dnnLogin.Visible = False
Else
Dim cmdLogin As LinkButton = CType(Me.dnnLogin.FindControl("cmdLogin"), LinkButton)
cmdLogin.Text = String.Format("{0}", cmdLogin.Text)
cmdLogin.ControlStyle.Reset()
End If
If Not Me.ShowUserTab Then
Me.dnnUser.Visible = False
Else
Dim cmdRegister As LinkButton = CType(Me.dnnUser.FindControl("cmdRegister"), LinkButton)
cmdRegister.Text = String.Format("{0}", cmdRegister.Text)
cmdRegister.ControlStyle.Reset()
End If
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Sub
Private Function GetMenuHtml() As String
Try
Dim objTabController As New TabController
Dim i, iRootGroupId As Integer
Dim StartingItemId As Integer
Dim menuHtml As New StringBuilder()
menuHtml.AppendLine("")
Dim objPortalTabs As ArrayList
GetShowOnlyCurrent(objTabController, StartingItemId, iRootGroupId)
For i = 0 To PortalSettings.DesktopTabs.Count - 1
Dim nTabInfo As TabInfo = DirectCast(PortalSettings.DesktopTabs(i), TabInfo)
If IsShownItem(nTabInfo) Then
If CheckShowOnlyCurrent(nTabInfo.TabID, nTabInfo.ParentId, StartingItemId, iRootGroupId) Then
menuHtml.Append(Me.RenderMenuItem(nTabInfo.TabID))
End If
End If
Next i
If Me.ShowLoginTab Or Me.ShowUserTab Then
menuHtml.Append("- ")
End If
Return menuHtml.ToString
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Function
Private Function IsShownItem(ByVal item As TabInfo) As Boolean
If Not (item.IsDeleted) And item.IsVisible Then
Return True
ElseIf (item.IsDeleted And Not (Me._showDeletedTabs)) Or (Not (item.IsVisible) And Not (Me._showHiddenTabs)) Then
Return False
Else
Return True
End If
End Function
Private Function RenderMenuItem(ByVal itemId As Integer) As String
Try
Dim itemHtml As New StringBuilder
Dim tabController As TabController = New TabController
Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, False)
If Not (PortalSecurity.IsInRoles(tabInfo.AuthorizedRoles)) Then Return String.Empty
itemHtml.Append("
- ")
itemHtml.Append(tabInfo.TabName)
itemHtml.Append("")
itemHtml.Append(RenderChildItems(itemId))
itemHtml.Append("
")
Return itemHtml.ToString
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Function
Private Function RenderChildItems(ByVal itemId As Integer) As String
Dim childItemsHtml As New Text.StringBuilder
Dim tabController As TabController = New TabController
Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, True)
If tabController.GetTabsByParentId(itemId).Count = 0 Then Return String.Empty
childItemsHtml.Append("")
For Each childTab As TabInfo In tabController.GetTabsByParentId(itemId)
If IsShownItem(childTab) Then
childItemsHtml.Append(RenderMenuItem(childTab.TabID))
End If
Next
childItemsHtml.Append(" ")
If childItemsHtml.Length = 9 Then Return String.Empty
Return childItemsHtml.ToString()
End Function
Private Sub GetShowOnlyCurrent(ByVal objTabController As TabController, ByRef StartingItemId As Integer, ByRef iRootGroupId As Integer)
StartingItemId = 0
iRootGroupId = 0
'check if we have a value to work with
If (ShowOnlyCurrent = String.Empty) Then
Exit Sub
End If
'check if user specified an ID
If (Char.IsDigit(ShowOnlyCurrent.Chars(0))) Then
Try
StartingItemId = Integer.Parse(ShowOnlyCurrent)
Catch ex As Exception
End Try
End If
'check if user specified a page name
If (ShowOnlyCurrent.StartsWith("PageItem:")) Then
Dim temptab As TabInfo = objTabController.GetTabByName(ShowOnlyCurrent.Substring(("PageItem:").Length), PortalSettings.PortalId)
If (Not temptab Is Nothing) Then
StartingItemId = temptab.TabID
End If
End If
'RootItem
If ("RootItem" = ShowOnlyCurrent) Then
iRootGroupId = PortalSettings.ActiveTab.TabID
While (CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId <> -1)
iRootGroupId = CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId
End While
End If
End Sub
Private Function CheckShowOnlyCurrent(ByVal tabId As Integer, ByVal parentId As Integer, ByVal StartingItemId As Integer, ByVal iRootGroupId As Integer) As Boolean
If _
(String.Empty = ShowOnlyCurrent AndAlso parentId = -1) OrElse _
("ChildItems" = ShowOnlyCurrent AndAlso parentId = PortalSettings.ActiveTab.TabID) OrElse _
("CurrentItem" = ShowOnlyCurrent AndAlso tabId = PortalSettings.ActiveTab.TabID) OrElse _
("RootItem" = ShowOnlyCurrent AndAlso iRootGroupId = parentId) OrElse _
(StartingItemId > 0 AndAlso parentId = StartingItemId) _
Then
Return True
Else
Return False
End If
End Function
End Class
End Namespace
Save and close the File.
In your Export-File find "Page.asp". Open this.
Find the Line:
Add the ShowOnlyCurrent::
That is it.
Nice Day
Sorry for my English, my German is better ;-)
</span>", cmdLogin.Text)
cmdLogin.ControlStyle.Reset()
End If
If Not Me.ShowUserTab Then
Me.dnnUser.Visible = False
Else
Dim cmdRegister As LinkButton = CType(Me.dnnUser.FindControl("cmdRegister"), LinkButton)
cmdRegister.Text = String.Format("<span class=""l""></span><span class=""r""></span><span class=""t"">Ok, here is the Answer:
Only Artitsteer 2.3!
Search the Install:
C:\Programme\Artisteer 2\Library\Data\Templates\DotNetNuke\Export\Files\Common\Menu
Open the File: ArtMenuSO.ascx.vb and delete the Code
Inside this Code:
Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DotNetNuke
Imports DotNetNuke.Common.Globals
Imports DotNetNuke.Services.Exceptions.Exceptions
Imports DotNetNuke.Entities.Modules
Imports DotNetNuke.Entities.Tabs
Imports DotNetNuke.Security
Imports System.Text
Namespace ArtMenuSkinObject
Partial Public Class ArtMenuSO
Inherits DotNetNuke.UI.Skins.SkinObjectBase
Private _showHiddenTabs As Boolean = False
Private _showDeletedTabs As Boolean = False
Private _showAdminTabs As Boolean = True
Private _showLoginTab As Boolean = True
Private _showUserTab As Boolean = True
Private _ShowOnlyCurrent As String = String.Empty
Public Property ShowOnlyCurrent() As String
Get
Return _ShowOnlyCurrent
End Get
Set(ByVal value As String)
_ShowOnlyCurrent = value
End Set
End Property
Public Property ShowHiddenTabs() As String
Get
Return _showHiddenTabs.ToString()
End Get
Set(ByVal value As String)
If Not (String.IsNullOrEmpty(value)) Then
_showHiddenTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowDeletedTabs() As String
Get
Return _showDeletedTabs.ToString()
End Get
Set(ByVal value As String)
If Not (String.IsNullOrEmpty(value)) Then
_showDeletedTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowAdminTabs() As Boolean
Get
Return _showAdminTabs.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showAdminTabs = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowLoginTab() As Boolean
Get
Return _showLoginTab.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showLoginTab = Boolean.Parse(value)
End If
End Set
End Property
Public Property ShowUserTab() As Boolean
Get
Return _showUserTab.ToString()
End Get
Set(ByVal value As Boolean)
If Not (String.IsNullOrEmpty(value)) Then
_showUserTab = Boolean.Parse(value)
End If
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Try
Me.litMenuHtml.Text = GetMenuHtml()
If Me.ShowLoginTab Or Me.ShowUserTab Then
Me.litMenuHtmlTail.Text = ""
End If
If Me.ShowLoginTab And Me.ShowUserTab Then
Me.litMenuTokensSeparator.Visible = True
Me.litMenuTokensSeparator.Text = "- "
End If
Me.litMenuHtmlTail.Text &= "
"
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Sub
Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender
Try
If Not Me.ShowLoginTab Then
Me.dnnLogin.Visible = False
Else
Dim cmdLogin As LinkButton = CType(Me.dnnLogin.FindControl("cmdLogin"), LinkButton)
cmdLogin.Text = String.Format("{0}", cmdLogin.Text)
cmdLogin.ControlStyle.Reset()
End If
If Not Me.ShowUserTab Then
Me.dnnUser.Visible = False
Else
Dim cmdRegister As LinkButton = CType(Me.dnnUser.FindControl("cmdRegister"), LinkButton)
cmdRegister.Text = String.Format("{0}", cmdRegister.Text)
cmdRegister.ControlStyle.Reset()
End If
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Sub
Private Function GetMenuHtml() As String
Try
Dim objTabController As New TabController
Dim i, iRootGroupId As Integer
Dim StartingItemId As Integer
Dim menuHtml As New StringBuilder()
menuHtml.AppendLine("")
Dim objPortalTabs As ArrayList
GetShowOnlyCurrent(objTabController, StartingItemId, iRootGroupId)
For i = 0 To PortalSettings.DesktopTabs.Count - 1
Dim nTabInfo As TabInfo = DirectCast(PortalSettings.DesktopTabs(i), TabInfo)
If IsShownItem(nTabInfo) Then
If CheckShowOnlyCurrent(nTabInfo.TabID, nTabInfo.ParentId, StartingItemId, iRootGroupId) Then
menuHtml.Append(Me.RenderMenuItem(nTabInfo.TabID))
End If
End If
Next i
If Me.ShowLoginTab Or Me.ShowUserTab Then
menuHtml.Append("- ")
End If
Return menuHtml.ToString
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Function
Private Function IsShownItem(ByVal item As TabInfo) As Boolean
If Not (item.IsDeleted) And item.IsVisible Then
Return True
ElseIf (item.IsDeleted And Not (Me._showDeletedTabs)) Or (Not (item.IsVisible) And Not (Me._showHiddenTabs)) Then
Return False
Else
Return True
End If
End Function
Private Function RenderMenuItem(ByVal itemId As Integer) As String
Try
Dim itemHtml As New StringBuilder
Dim tabController As TabController = New TabController
Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, False)
If Not (PortalSecurity.IsInRoles(tabInfo.AuthorizedRoles)) Then Return String.Empty
itemHtml.Append("
- ")
itemHtml.Append(tabInfo.TabName)
itemHtml.Append("")
itemHtml.Append(RenderChildItems(itemId))
itemHtml.Append("
")
Return itemHtml.ToString
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Function
Private Function RenderChildItems(ByVal itemId As Integer) As String
Dim childItemsHtml As New Text.StringBuilder
Dim tabController As TabController = New TabController
Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, True)
If tabController.GetTabsByParentId(itemId).Count = 0 Then Return String.Empty
childItemsHtml.Append("")
For Each childTab As TabInfo In tabController.GetTabsByParentId(itemId)
If IsShownItem(childTab) Then
childItemsHtml.Append(RenderMenuItem(childTab.TabID))
End If
Next
childItemsHtml.Append(" ")
If childItemsHtml.Length = 9 Then Return String.Empty
Return childItemsHtml.ToString()
End Function
Private Sub GetShowOnlyCurrent(ByVal objTabController As TabController, ByRef StartingItemId As Integer, ByRef iRootGroupId As Integer)
StartingItemId = 0
iRootGroupId = 0
'check if we have a value to work with
If (ShowOnlyCurrent = String.Empty) Then
Exit Sub
End If
'check if user specified an ID
If (Char.IsDigit(ShowOnlyCurrent.Chars(0))) Then
Try
StartingItemId = Integer.Parse(ShowOnlyCurrent)
Catch ex As Exception
End Try
End If
'check if user specified a page name
If (ShowOnlyCurrent.StartsWith("PageItem:")) Then
Dim temptab As TabInfo = objTabController.GetTabByName(ShowOnlyCurrent.Substring(("PageItem:").Length), PortalSettings.PortalId)
If (Not temptab Is Nothing) Then
StartingItemId = temptab.TabID
End If
End If
'RootItem
If ("RootItem" = ShowOnlyCurrent) Then
iRootGroupId = PortalSettings.ActiveTab.TabID
While (CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId <> -1)
iRootGroupId = CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId
End While
End If
End Sub
Private Function CheckShowOnlyCurrent(ByVal tabId As Integer, ByVal parentId As Integer, ByVal StartingItemId As Integer, ByVal iRootGroupId As Integer) As Boolean
If _
(String.Empty = ShowOnlyCurrent AndAlso parentId = -1) OrElse _
("ChildItems" = ShowOnlyCurrent AndAlso parentId = PortalSettings.ActiveTab.TabID) OrElse _
("CurrentItem" = ShowOnlyCurrent AndAlso tabId = PortalSettings.ActiveTab.TabID) OrElse _
("RootItem" = ShowOnlyCurrent AndAlso iRootGroupId = parentId) OrElse _
(StartingItemId > 0 AndAlso parentId = StartingItemId) _
Then
Return True
Else
Return False
End If
End Function
End Class
End Namespace
Save and close the File.
In your Export-File find "Page.asp". Open this.
Find the Line:
Add the ShowOnlyCurrent::
That is it.
Nice Day
Sorry for my English, my German is better ;-)
</span>", cmdRegister.Text)
cmdRegister.ControlStyle.Reset()
End If
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Sub
Private Function GetMenuHtml() As String
Try
Dim objTabController As New TabController
Dim i, iRootGroupId As Integer
Dim StartingItemId As Integer
Dim menuHtml As New StringBuilder()
menuHtml.AppendLine("<div class=""art-nav""><div class=""l""></div><div class=""r""></div><div class=""art-nav-center""><ul class=""art-menu"">")
Dim objPortalTabs As ArrayList
GetShowOnlyCurrent(objTabController, StartingItemId, iRootGroupId)
For i = 0 To PortalSettings.DesktopTabs.Count - 1
Dim nTabInfo As TabInfo = DirectCast(PortalSettings.DesktopTabs(i), TabInfo)
If IsShownItem(nTabInfo) Then
If CheckShowOnlyCurrent(nTabInfo.TabID, nTabInfo.ParentId, StartingItemId, iRootGroupId) Then
menuHtml.Append(Me.RenderMenuItem(nTabInfo.TabID))
End If
End If
Next i
If Me.ShowLoginTab Or Me.ShowUserTab Then
menuHtml.Append("<li>")
End If
Return menuHtml.ToString
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Function
Private Function IsShownItem(ByVal item As TabInfo) As Boolean
If Not (item.IsDeleted) And item.IsVisible Then
Return True
ElseIf (item.IsDeleted And Not (Me._showDeletedTabs)) Or (Not (item.IsVisible) And Not (Me._showHiddenTabs)) Then
Return False
Else
Return True
End If
End Function
Private Function RenderMenuItem(ByVal itemId As Integer) As String
Try
Dim itemHtml As New StringBuilder
Dim tabController As TabController = New TabController
Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, False)
If Not (PortalSecurity.IsInRoles(tabInfo.AuthorizedRoles)) Then Return String.Empty
itemHtml.Append("<li><a href=""")
itemHtml.Append(tabInfo.FullUrl)
itemHtml.Append("""")
If tabInfo.TabID = PortalSettings.ActiveTab.TabID Then
itemHtml.Append(" class="" active""")
End If
itemHtml.Append("><span class=""l""></span><span class=""r""></span><span class=""t"">")
itemHtml.Append(tabInfo.TabName)
itemHtml.Append("</span></a>")
itemHtml.Append(RenderChildItems(itemId))
itemHtml.Append("</li>")
Return itemHtml.ToString
Catch ex As Exception
ProcessModuleLoadException(Me, ex)
End Try
End Function
Private Function RenderChildItems(ByVal itemId As Integer) As String
Dim childItemsHtml As New Text.StringBuilder
Dim tabController As TabController = New TabController
Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, True)
If tabController.GetTabsByParentId(itemId).Count = 0 Then Return String.Empty
childItemsHtml.Append("<ul>")
For Each childTab As TabInfo In tabController.GetTabsByParentId(itemId)
If IsShownItem(childTab) Then
childItemsHtml.Append(RenderMenuItem(childTab.TabID))
End If
Next
childItemsHtml.Append("</ul>")
If childItemsHtml.Length = 9 Then Return String.Empty
Return childItemsHtml.ToString()
End Function
Private Sub GetShowOnlyCurrent(ByVal objTabController As TabController, ByRef StartingItemId As Integer, ByRef iRootGroupId As Integer)
StartingItemId = 0
iRootGroupId = 0
'check if we have a value to work with
If (ShowOnlyCurrent = String.Empty) Then
Exit Sub
End If
'check if user specified an ID
If (Char.IsDigit(ShowOnlyCurrent.Chars(0))) Then
Try
StartingItemId = Integer.Parse(ShowOnlyCurrent)
Catch ex As Exception
End Try
End If
'check if user specified a page name
If (ShowOnlyCurrent.StartsWith("PageItem:")) Then
Dim temptab As TabInfo = objTabController.GetTabByName(ShowOnlyCurrent.Substring(("PageItem:").Length), PortalSettings.PortalId)
If (Not temptab Is Nothing) Then
StartingItemId = temptab.TabID
End If
End If
'RootItem
If ("RootItem" = ShowOnlyCurrent) Then
iRootGroupId = PortalSettings.ActiveTab.TabID
While (CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId <> -1)
iRootGroupId = CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId
End While
End If
End Sub
Private Function CheckShowOnlyCurrent(ByVal tabId As Integer, ByVal parentId As Integer, ByVal StartingItemId As Integer, ByVal iRootGroupId As Integer) As Boolean
If _
(String.Empty = ShowOnlyCurrent AndAlso parentId = -1) OrElse _
("ChildItems" = ShowOnlyCurrent AndAlso parentId = PortalSettings.ActiveTab.TabID) OrElse _
("CurrentItem" = ShowOnlyCurrent AndAlso tabId = PortalSettings.ActiveTab.TabID) OrElse _
("RootItem" = ShowOnlyCurrent AndAlso iRootGroupId = parentId) OrElse _
(StartingItemId > 0 AndAlso parentId = StartingItemId) _
Then
Return True
Else
Return False
End If
End Function
End Class
End Namespace
Save and close the File.
In your Export-File find "Page.asp". Open this.
Find the Line:
<dnn:ARTMENU ID="ArtMenu1" ShowHiddenTabs="False" ShowAdminTabs="True" ShowDeletedTabs="False" ShowLoginTab="True" ShowUserTab="True" runat="server" />
Add the ShowOnlyCurrent::
<dnn:ARTMENU ID="ArtMenu1" ShowHiddenTabs="False" ShowAdminTabs="True" ShowDeletedTabs="False" ShowLoginTab="True" ShowUserTab="True" ShowOnlyCurrent="PageItem:xxxx" runat="server" />
That is it.
Nice Day
Sorry for my English, my German is better
|
|
Chris
|
Quote HannesS:
Hi,
how can I limit the menu on a Submenuitem?
In DNN menu that goes with ShowOnlyCurrent.
Thx,
Hannes
Hannes, vielen dank for the great code sample. I used it with the latest version to upgrade my vertical menu for this functionality.
|
|
HannesS
|
I have see, the code-block is not correct.
Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports DotNetNuke Imports DotNetNuke.Common.Globals Imports DotNetNuke.Services.Exceptions.Exceptions Imports DotNetNuke.Entities.Modules Imports DotNetNuke.Entities.Tabs Imports DotNetNuke.Security Imports System.Text Namespace ArtMenuSkinObject Partial Public Class ArtMenuSO Inherits DotNetNuke.UI.Skins.SkinObjectBase Private _showHiddenTabs As Boolean = False Private _showDeletedTabs As Boolean = False Private _showAdminTabs As Boolean = True Private _showLoginTab As Boolean = True Private _showUserTab As Boolean = True Private _ShowOnlyCurrent As String = String.Empty Public Property ShowOnlyCurrent() As String Get Return _ShowOnlyCurrent End Get Set(ByVal value As String) _ShowOnlyCurrent = value End Set End Property Public Property ShowHiddenTabs() As String Get Return False '_showHiddenTabs.ToString() End Get Set(ByVal value As String) If Not (String.IsNullOrEmpty(value)) Then _showHiddenTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowDeletedTabs() As String Get Return False '_showDeletedTabs.ToString() End Get Set(ByVal value As String) If Not (String.IsNullOrEmpty(value)) Then _showDeletedTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowAdminTabs() As Boolean Get Return False '_showAdminTabs.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showAdminTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowLoginTab() As Boolean Get Return False '_showLoginTab.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showLoginTab = Boolean.Parse(value) End If End Set End Property Public Property ShowUserTab() As Boolean Get Return False '_showUserTab.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showUserTab = Boolean.Parse(value) End If End Set End Property Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Me.litMenuHtml.Text = GetMenuHtml() If Me.ShowLoginTab Or Me.ShowUserTab Then Me.litMenuHtmlTail.Text = "</li>" End If If Me.ShowLoginTab And Me.ShowUserTab Then Me.litMenuTokensSeparator.Visible = True Me.litMenuTokensSeparator.Text = "</li><li>" End If Me.litMenuHtmlTail.Text &= "</ul></div></div>" Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Sub Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender Try If Not Me.ShowLoginTab Then Me.dnnLogin.Visible = False Else Dim cmdLogin As LinkButton = CType(Me.dnnLogin.FindControl("cmdLogin"), LinkButton) cmdLogin.Text = String.Format("<span class=""l""></span><span class=""r""></span><span class=""t"">I have see, the code-block is not correct.
[code]Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports DotNetNuke Imports DotNetNuke.Common.Globals Imports DotNetNuke.Services.Exceptions.Exceptions Imports DotNetNuke.Entities.Modules Imports DotNetNuke.Entities.Tabs Imports DotNetNuke.Security Imports System.Text Namespace ArtMenuSkinObject Partial Public Class ArtMenuSO Inherits DotNetNuke.UI.Skins.SkinObjectBase Private _showHiddenTabs As Boolean = False Private _showDeletedTabs As Boolean = False Private _showAdminTabs As Boolean = True Private _showLoginTab As Boolean = True Private _showUserTab As Boolean = True Private _ShowOnlyCurrent As String = String.Empty Public Property ShowOnlyCurrent() As String Get Return _ShowOnlyCurrent End Get Set(ByVal value As String) _ShowOnlyCurrent = value End Set End Property Public Property ShowHiddenTabs() As String Get Return False '_showHiddenTabs.ToString() End Get Set(ByVal value As String) If Not (String.IsNullOrEmpty(value)) Then _showHiddenTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowDeletedTabs() As String Get Return False '_showDeletedTabs.ToString() End Get Set(ByVal value As String) If Not (String.IsNullOrEmpty(value)) Then _showDeletedTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowAdminTabs() As Boolean Get Return False '_showAdminTabs.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showAdminTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowLoginTab() As Boolean Get Return False '_showLoginTab.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showLoginTab = Boolean.Parse(value) End If End Set End Property Public Property ShowUserTab() As Boolean Get Return False '_showUserTab.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showUserTab = Boolean.Parse(value) End If End Set End Property Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Me.litMenuHtml.Text = GetMenuHtml() If Me.ShowLoginTab Or Me.ShowUserTab Then Me.litMenuHtmlTail.Text = "" End If If Me.ShowLoginTab And Me.ShowUserTab Then Me.litMenuTokensSeparator.Visible = True Me.litMenuTokensSeparator.Text = " " End If Me.litMenuHtmlTail.Text &= "" Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Sub Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender Try If Not Me.ShowLoginTab Then Me.dnnLogin.Visible = False Else Dim cmdLogin As LinkButton = CType(Me.dnnLogin.FindControl("cmdLogin"), LinkButton) cmdLogin.Text = String.Format("{0}", cmdLogin.Text) cmdLogin.ControlStyle.Reset() End If If Not Me.ShowUserTab Then Me.dnnUser.Visible = False Else Dim cmdRegister As LinkButton = CType(Me.dnnUser.FindControl("cmdRegister"), LinkButton) cmdRegister.Text = String.Format("{0}", cmdRegister.Text) cmdRegister.ControlStyle.Reset() End If Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Sub Private Function GetMenuHtml() As String Try Dim objTabController As New TabController Dim i, iRootGroupId As Integer Dim StartingItemId As Integer Dim menuHtml As New StringBuilder() menuHtml.AppendLine("") Dim objPortalTabs As ArrayList GetShowOnlyCurrent(objTabController, StartingItemId, iRootGroupId) For i = 0 To PortalSettings.DesktopTabs.Count - 1 Dim nTabInfo As TabInfo = DirectCast(PortalSettings.DesktopTabs(i), TabInfo) If IsShownItem(nTabInfo) Then If CheckShowOnlyCurrent(nTabInfo.TabID, nTabInfo.ParentId, StartingItemId, iRootGroupId) Then menuHtml.Append(Me.RenderMenuItem(nTabInfo.TabID)) End If End If Next i If Me.ShowLoginTab Or Me.ShowUserTab Then menuHtml.Append("- ") End If Return menuHtml.ToString Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Function Private Function IsShownItem(ByVal item As TabInfo) As Boolean If Not (item.IsDeleted) And item.IsVisible Then Return True ElseIf (item.IsDeleted And Not (Me._showDeletedTabs)) Or (Not (item.IsVisible) And Not (Me._showHiddenTabs)) Then Return False Else Return True End If End Function Private Function RenderMenuItem(ByVal itemId As Integer) As String Try Dim itemHtml As New StringBuilder Dim tabController As TabController = New TabController Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, False) If Not (PortalSecurity.IsInRoles(tabInfo.AuthorizedRoles)) Then Return String.Empty itemHtml.Append("
- ") itemHtml.Append(tabInfo.TabName) itemHtml.Append("") itemHtml.Append(RenderChildItems(itemId)) itemHtml.Append("
") Return itemHtml.ToString Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Function Private Function RenderChildItems(ByVal itemId As Integer) As String Dim childItemsHtml As New Text.StringBuilder Dim tabController As TabController = New TabController Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, True) If tabController.GetTabsByParentId(itemId).Count = 0 Then Return String.Empty childItemsHtml.Append("") For Each childTab As TabInfo In tabController.GetTabsByParentId(itemId) If IsShownItem(childTab) Then childItemsHtml.Append(RenderMenuItem(childTab.TabID)) End If Next childItemsHtml.Append(" ") If childItemsHtml.Length = 9 Then Return String.Empty Return childItemsHtml.ToString() End Function Private Sub GetShowOnlyCurrent(ByVal objTabController As TabController, ByRef StartingItemId As Integer, ByRef iRootGroupId As Integer) StartingItemId = 0 iRootGroupId = 0 'check if we have a value to work with If (ShowOnlyCurrent = String.Empty) Then Exit Sub End If 'check if user specified an ID If (Char.IsDigit(ShowOnlyCurrent.Chars(0))) Then Try StartingItemId = Integer.Parse(ShowOnlyCurrent) Catch ex As Exception End Try End If 'check if user specified a page name If (ShowOnlyCurrent.StartsWith("PageItem:")) Then Dim temptab As TabInfo = objTabController.GetTabByName(ShowOnlyCurrent.Substring(("PageItem:").Length), PortalSettings.PortalId) If (Not temptab Is Nothing) Then StartingItemId = temptab.TabID End If End If 'RootItem If ("RootItem" = ShowOnlyCurrent) Then iRootGroupId = PortalSettings.ActiveTab.TabID While (CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId <> -1) iRootGroupId = CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId End While End If End Sub Private Function CheckShowOnlyCurrent(ByVal tabId As Integer, ByVal parentId As Integer, ByVal StartingItemId As Integer, ByVal iRootGroupId As Integer) As Boolean If _ (String.Empty = ShowOnlyCurrent AndAlso parentId = -1) OrElse _ ("ChildItems" = ShowOnlyCurrent AndAlso parentId = PortalSettings.ActiveTab.TabID) OrElse _ ("CurrentItem" = ShowOnlyCurrent AndAlso tabId = PortalSettings.ActiveTab.TabID) OrElse _ ("RootItem" = ShowOnlyCurrent AndAlso iRootGroupId = parentId) OrElse _ (StartingItemId > 0 AndAlso parentId = StartingItemId) _ Then Return True Else Return False End If End Function End Class End Namespace [/code]
my email: hjs[at]directbox.com
nice day</span>", cmdLogin.Text) cmdLogin.ControlStyle.Reset() End If If Not Me.ShowUserTab Then Me.dnnUser.Visible = False Else Dim cmdRegister As LinkButton = CType(Me.dnnUser.FindControl("cmdRegister"), LinkButton) cmdRegister.Text = String.Format("<span class=""l""></span><span class=""r""></span><span class=""t"">I have see, the code-block is not correct.
[code]Imports System Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Imports DotNetNuke Imports DotNetNuke.Common.Globals Imports DotNetNuke.Services.Exceptions.Exceptions Imports DotNetNuke.Entities.Modules Imports DotNetNuke.Entities.Tabs Imports DotNetNuke.Security Imports System.Text Namespace ArtMenuSkinObject Partial Public Class ArtMenuSO Inherits DotNetNuke.UI.Skins.SkinObjectBase Private _showHiddenTabs As Boolean = False Private _showDeletedTabs As Boolean = False Private _showAdminTabs As Boolean = True Private _showLoginTab As Boolean = True Private _showUserTab As Boolean = True Private _ShowOnlyCurrent As String = String.Empty Public Property ShowOnlyCurrent() As String Get Return _ShowOnlyCurrent End Get Set(ByVal value As String) _ShowOnlyCurrent = value End Set End Property Public Property ShowHiddenTabs() As String Get Return False '_showHiddenTabs.ToString() End Get Set(ByVal value As String) If Not (String.IsNullOrEmpty(value)) Then _showHiddenTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowDeletedTabs() As String Get Return False '_showDeletedTabs.ToString() End Get Set(ByVal value As String) If Not (String.IsNullOrEmpty(value)) Then _showDeletedTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowAdminTabs() As Boolean Get Return False '_showAdminTabs.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showAdminTabs = Boolean.Parse(value) End If End Set End Property Public Property ShowLoginTab() As Boolean Get Return False '_showLoginTab.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showLoginTab = Boolean.Parse(value) End If End Set End Property Public Property ShowUserTab() As Boolean Get Return False '_showUserTab.ToString() End Get Set(ByVal value As Boolean) If Not (String.IsNullOrEmpty(value)) Then _showUserTab = Boolean.Parse(value) End If End Set End Property Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Me.litMenuHtml.Text = GetMenuHtml() If Me.ShowLoginTab Or Me.ShowUserTab Then Me.litMenuHtmlTail.Text = "" End If If Me.ShowLoginTab And Me.ShowUserTab Then Me.litMenuTokensSeparator.Visible = True Me.litMenuTokensSeparator.Text = "- " End If Me.litMenuHtmlTail.Text &= "
" Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Sub Private Sub Page_PreRender(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.PreRender Try If Not Me.ShowLoginTab Then Me.dnnLogin.Visible = False Else Dim cmdLogin As LinkButton = CType(Me.dnnLogin.FindControl("cmdLogin"), LinkButton) cmdLogin.Text = String.Format("{0}", cmdLogin.Text) cmdLogin.ControlStyle.Reset() End If If Not Me.ShowUserTab Then Me.dnnUser.Visible = False Else Dim cmdRegister As LinkButton = CType(Me.dnnUser.FindControl("cmdRegister"), LinkButton) cmdRegister.Text = String.Format("{0}", cmdRegister.Text) cmdRegister.ControlStyle.Reset() End If Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Sub Private Function GetMenuHtml() As String Try Dim objTabController As New TabController Dim i, iRootGroupId As Integer Dim StartingItemId As Integer Dim menuHtml As New StringBuilder() menuHtml.AppendLine("") Dim objPortalTabs As ArrayList GetShowOnlyCurrent(objTabController, StartingItemId, iRootGroupId) For i = 0 To PortalSettings.DesktopTabs.Count - 1 Dim nTabInfo As TabInfo = DirectCast(PortalSettings.DesktopTabs(i), TabInfo) If IsShownItem(nTabInfo) Then If CheckShowOnlyCurrent(nTabInfo.TabID, nTabInfo.ParentId, StartingItemId, iRootGroupId) Then menuHtml.Append(Me.RenderMenuItem(nTabInfo.TabID)) End If End If Next i If Me.ShowLoginTab Or Me.ShowUserTab Then menuHtml.Append("- ") End If Return menuHtml.ToString Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Function Private Function IsShownItem(ByVal item As TabInfo) As Boolean If Not (item.IsDeleted) And item.IsVisible Then Return True ElseIf (item.IsDeleted And Not (Me._showDeletedTabs)) Or (Not (item.IsVisible) And Not (Me._showHiddenTabs)) Then Return False Else Return True End If End Function Private Function RenderMenuItem(ByVal itemId As Integer) As String Try Dim itemHtml As New StringBuilder Dim tabController As TabController = New TabController Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, False) If Not (PortalSecurity.IsInRoles(tabInfo.AuthorizedRoles)) Then Return String.Empty itemHtml.Append("
- ") itemHtml.Append(tabInfo.TabName) itemHtml.Append("") itemHtml.Append(RenderChildItems(itemId)) itemHtml.Append("
") Return itemHtml.ToString Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Function Private Function RenderChildItems(ByVal itemId As Integer) As String Dim childItemsHtml As New Text.StringBuilder Dim tabController As TabController = New TabController Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, True) If tabController.GetTabsByParentId(itemId).Count = 0 Then Return String.Empty childItemsHtml.Append("") For Each childTab As TabInfo In tabController.GetTabsByParentId(itemId) If IsShownItem(childTab) Then childItemsHtml.Append(RenderMenuItem(childTab.TabID)) End If Next childItemsHtml.Append(" ") If childItemsHtml.Length = 9 Then Return String.Empty Return childItemsHtml.ToString() End Function Private Sub GetShowOnlyCurrent(ByVal objTabController As TabController, ByRef StartingItemId As Integer, ByRef iRootGroupId As Integer) StartingItemId = 0 iRootGroupId = 0 'check if we have a value to work with If (ShowOnlyCurrent = String.Empty) Then Exit Sub End If 'check if user specified an ID If (Char.IsDigit(ShowOnlyCurrent.Chars(0))) Then Try StartingItemId = Integer.Parse(ShowOnlyCurrent) Catch ex As Exception End Try End If 'check if user specified a page name If (ShowOnlyCurrent.StartsWith("PageItem:")) Then Dim temptab As TabInfo = objTabController.GetTabByName(ShowOnlyCurrent.Substring(("PageItem:").Length), PortalSettings.PortalId) If (Not temptab Is Nothing) Then StartingItemId = temptab.TabID End If End If 'RootItem If ("RootItem" = ShowOnlyCurrent) Then iRootGroupId = PortalSettings.ActiveTab.TabID While (CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId <> -1) iRootGroupId = CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId End While End If End Sub Private Function CheckShowOnlyCurrent(ByVal tabId As Integer, ByVal parentId As Integer, ByVal StartingItemId As Integer, ByVal iRootGroupId As Integer) As Boolean If _ (String.Empty = ShowOnlyCurrent AndAlso parentId = -1) OrElse _ ("ChildItems" = ShowOnlyCurrent AndAlso parentId = PortalSettings.ActiveTab.TabID) OrElse _ ("CurrentItem" = ShowOnlyCurrent AndAlso tabId = PortalSettings.ActiveTab.TabID) OrElse _ ("RootItem" = ShowOnlyCurrent AndAlso iRootGroupId = parentId) OrElse _ (StartingItemId > 0 AndAlso parentId = StartingItemId) _ Then Return True Else Return False End If End Function End Class End Namespace [/code]
my email: hjs[at]directbox.com
nice day</span>", cmdRegister.Text) cmdRegister.ControlStyle.Reset() End If Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Sub Private Function GetMenuHtml() As String Try Dim objTabController As New TabController Dim i, iRootGroupId As Integer Dim StartingItemId As Integer Dim menuHtml As New StringBuilder() menuHtml.AppendLine("<div class=""art-nav""><div class=""l""></div><div class=""r""></div><div class=""art-nav-center""><ul class=""art-menu"">") Dim objPortalTabs As ArrayList GetShowOnlyCurrent(objTabController, StartingItemId, iRootGroupId) For i = 0 To PortalSettings.DesktopTabs.Count - 1 Dim nTabInfo As TabInfo = DirectCast(PortalSettings.DesktopTabs(i), TabInfo) If IsShownItem(nTabInfo) Then If CheckShowOnlyCurrent(nTabInfo.TabID, nTabInfo.ParentId, StartingItemId, iRootGroupId) Then menuHtml.Append(Me.RenderMenuItem(nTabInfo.TabID)) End If End If Next i If Me.ShowLoginTab Or Me.ShowUserTab Then menuHtml.Append("<li>") End If Return menuHtml.ToString Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Function Private Function IsShownItem(ByVal item As TabInfo) As Boolean If Not (item.IsDeleted) And item.IsVisible Then Return True ElseIf (item.IsDeleted And Not (Me._showDeletedTabs)) Or (Not (item.IsVisible) And Not (Me._showHiddenTabs)) Then Return False Else Return True End If End Function Private Function RenderMenuItem(ByVal itemId As Integer) As String Try Dim itemHtml As New StringBuilder Dim tabController As TabController = New TabController Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, False) If Not (PortalSecurity.IsInRoles(tabInfo.AuthorizedRoles)) Then Return String.Empty itemHtml.Append("<li><a href=""") itemHtml.Append(tabInfo.FullUrl) itemHtml.Append("""") If tabInfo.TabID = PortalSettings.ActiveTab.TabID Then itemHtml.Append(" class="" active""") End If itemHtml.Append("><span class=""l""></span><span class=""r""></span><span class=""t"">") itemHtml.Append(tabInfo.TabName) itemHtml.Append("</span></a>") itemHtml.Append(RenderChildItems(itemId)) itemHtml.Append("</li>") Return itemHtml.ToString Catch ex As Exception ProcessModuleLoadException(Me, ex) End Try End Function Private Function RenderChildItems(ByVal itemId As Integer) As String Dim childItemsHtml As New Text.StringBuilder Dim tabController As TabController = New TabController Dim tabInfo As TabInfo = tabController.GetTab(itemId, PortalSettings.PortalId, True) If tabController.GetTabsByParentId(itemId).Count = 0 Then Return String.Empty childItemsHtml.Append("<ul>") For Each childTab As TabInfo In tabController.GetTabsByParentId(itemId) If IsShownItem(childTab) Then childItemsHtml.Append(RenderMenuItem(childTab.TabID)) End If Next childItemsHtml.Append("</ul>") If childItemsHtml.Length = 9 Then Return String.Empty Return childItemsHtml.ToString() End Function Private Sub GetShowOnlyCurrent(ByVal objTabController As TabController, ByRef StartingItemId As Integer, ByRef iRootGroupId As Integer) StartingItemId = 0 iRootGroupId = 0 'check if we have a value to work with If (ShowOnlyCurrent = String.Empty) Then Exit Sub End If 'check if user specified an ID If (Char.IsDigit(ShowOnlyCurrent.Chars(0))) Then Try StartingItemId = Integer.Parse(ShowOnlyCurrent) Catch ex As Exception End Try End If 'check if user specified a page name If (ShowOnlyCurrent.StartsWith("PageItem:")) Then Dim temptab As TabInfo = objTabController.GetTabByName(ShowOnlyCurrent.Substring(("PageItem:").Length), PortalSettings.PortalId) If (Not temptab Is Nothing) Then StartingItemId = temptab.TabID End If End If 'RootItem If ("RootItem" = ShowOnlyCurrent) Then iRootGroupId = PortalSettings.ActiveTab.TabID While (CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId <> -1) iRootGroupId = CType(objTabController.GetTab(iRootGroupId), TabInfo).ParentId End While End If End Sub Private Function CheckShowOnlyCurrent(ByVal tabId As Integer, ByVal parentId As Integer, ByVal StartingItemId As Integer, ByVal iRootGroupId As Integer) As Boolean If _ (String.Empty = ShowOnlyCurrent AndAlso parentId = -1) OrElse _ ("ChildItems" = ShowOnlyCurrent AndAlso parentId = PortalSettings.ActiveTab.TabID) OrElse _ ("CurrentItem" = ShowOnlyCurrent AndAlso tabId = PortalSettings.ActiveTab.TabID) OrElse _ ("RootItem" = ShowOnlyCurrent AndAlso iRootGroupId = parentId) OrElse _ (StartingItemId > 0 AndAlso parentId = StartingItemId) _ Then Return True Else Return False End If End Function End Class End Namespace
my email: hjs[at]directbox.com
nice day
|
|
TheRune
|
Hello HannesS
Nice looking code, but would you mind telling me what it does? I'm not sure I know how "ShowOnlyCurrent" works
I'm looking for some way to display only the submenu items of the active tab, and it seems the artmenu can't do that. Yet
Kind Regards
TheRune
|
|
|
|