Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Help Building a Menu For DNNHelp Building a Menu For DNN
Previous
 
Next
New Post
10/11/2008 4:06 PM
 

Hi everybody my name is jean im building a custom menu for a dnn skin that im creating i have already build the user control that renders de menu items but i have a little problem with the menu, the problem consist in that when i log on into the site as a host it didn't render the HOST items in the menu just the admin list of items. Here is the code that im using to bind the menu items.

Public Sub BuildSiteMap2(ByVal PortalID As Integer)
            Dim URL As String
            Dim currentGroup As String
            Dim lastGroup As String = ""

            Me.ASPxMenu1.Items.Clear()

            ' add urls
            Dim intURLs As Integer = 0
            Dim objTabs As New TabController
            Dim Tabs As ArrayList = objTabs.GetTabs(PortalID)

            If Tabs.Count > 0 Then
                For Each objTab As TabInfo In Tabs
                    If objTab.IsDeleted = False AndAlso objTab.DisableLink = False AndAlso objTab.IsVisible AndAlso objTab.TabType = TabType.Normal AndAlso ((Null.IsNull(objTab.StartDate) = True OrElse objTab.StartDate < Now) AndAlso (Null.IsNull(objTab.EndDate) = True OrElse objTab.EndDate > Now)) Then
                        ' the crawler is an anonymous user therefore the site map will only contain publicly accessible pages
                        If PortalSecurity.IsInRoles(objTab.AuthorizedRoles) Then
                            SITEMAP_GROUPLOCATION = objTab.FullUrl.Split("/").Length - 4
                            Exit For
                        End If
                    End If
                Next
            Else
                SITEMAP_GROUPLOCATION = 2
            End If

            'Crear grupos
            For Each objTab As TabInfo In Tabs
                If objTab.IsDeleted = False AndAlso objTab.DisableLink = False AndAlso objTab.IsVisible AndAlso objTab.TabType = TabType.Normal AndAlso ((Null.IsNull(objTab.StartDate) = True OrElse objTab.StartDate < Now) AndAlso (Null.IsNull(objTab.EndDate) = True OrElse objTab.EndDate > Now)) Then
                    ' the crawler is an anonymous user therefore the site map will only contain publicly accessible pages
                    If PortalSecurity.IsInRoles(objTab.AuthorizedRoles) Then
                        If intURLs < SITEMAP_MAXURLS Then
                            intURLs += 1

                            currentGroup = objTab.FullUrl.Split("/")(SITEMAP_GROUPLOCATION)
                            'currentGroup = objTab.TabName

                            If currentGroup <> lastGroup Then
                                Me.ASPxMenu1.Items.Add(objTab.TabName, currentGroup, GetImgUrl(objTab.TabName))

                                lastGroup = currentGroup
                            End If
                        End If
                    End If
                End If
            Next

            'Agregar items a los grupos
            For Each objTab As TabInfo In Tabs
                If objTab.IsDeleted = False AndAlso objTab.DisableLink = False AndAlso objTab.IsVisible AndAlso objTab.TabType = TabType.Normal AndAlso ((Null.IsNull(objTab.StartDate) = True OrElse objTab.StartDate < Now) AndAlso (Null.IsNull(objTab.EndDate) = True OrElse objTab.EndDate > Now)) Then
                    ' the crawler is an anonymous user therefore the site map will only contain publicly accessible pages
                    If PortalSecurity.IsInRoles(objTab.AuthorizedRoles) Then
                        If intURLs < SITEMAP_MAXURLS Then
                            intURLs += 1

                            URL = objTab.FullUrl
                            currentGroup = URL.Split("/")(SITEMAP_GROUPLOCATION)

                            For i As Integer = 0 To ASPxMenu1.Items.Count - 1
                                If Me.ASPxMenu1.Items(i).Name = currentGroup Then

                                    Me.ASPxMenu1.Items(i).Items.Add(objTab.TabName, objTab.TabName, GetImgUrl(objTab.TabName), URL)
                                    Exit For
                                End If
                            Next
                        End If
                    End If
                End If
            Next

            'Verificar si no tiene mas de una pagina para poner como default
            For Each objTab As TabInfo In objTabs.GetTabs(PortalID)
                If objTab.IsDeleted = False AndAlso objTab.DisableLink = False AndAlso objTab.IsVisible AndAlso objTab.TabType = TabType.Normal AndAlso ((Null.IsNull(objTab.StartDate) = True OrElse objTab.StartDate < Now) AndAlso (Null.IsNull(objTab.EndDate) = True OrElse objTab.EndDate > Now)) Then
                    ' the crawler is an anonymous user therefore the site map will only contain publicly accessible pages
                    If PortalSecurity.IsInRoles(objTab.AuthorizedRoles) Then
                        If intURLs < SITEMAP_MAXURLS Then
                            intURLs += 1

                            URL = objTab.FullUrl
                            currentGroup = URL.Split("/")(SITEMAP_GROUPLOCATION)

                            If URL.ToLower.IndexOf(Request.Url.Host.ToLower) = -1 Then
                                URL = AddHTTP(Request.Url.Host) & URL
                            End If

                            For i As Integer = 0 To Me.ASPxMenu1.Items.Count - 1
                                If Me.ASPxMenu1.Items(i).Items.Count = 1 Then
                                    Me.ASPxMenu1.Items(i).NavigateUrl = Me.ASPxMenu1.Items(i).Items(0).NavigateUrl
                                    Me.ASPxMenu1.Items(i).Items.Clear()
                                    Exit For
                                End If
                                'Me.ASPxMenu1.Groups(i).Expanded = False
                            Next
                        End If
                    End If
                End If
            Next
        End Sub

Thanks in advance for the help that any of you guys can give.

Jean Carlos

 

 

 

 

 
New Post
10/12/2008 9:47 AM
 

Hi Jean,

Firstly we need to get the current user object by adding this function. Remember I assume that you did this inside a module, as it needs inherit PortalModuleBase

Protected Function GetCurrentUser() As UserInfo
    objUserInfo = New UserInfo()
    objUserInfo = UserController.GetCurrentUserInfo()
    If objUserInfo <> Nothing Then
        Return objUserInfo
    End If
    Return Nothing
End Function

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
    If Not Page.IsPostBack Then
        Dim isSuperUser As Boolean = False
        'get current userinfo
        Dim objUserInfo As New UserInfo()
        objUserInfo = GetCurrentUser()
        If objUserInfo <> Nothing Then
            isSuperUser = objUserInfo.IsSuperUser
        End If

        'add tab host
        If isSuperUser Then
            Dim objTabHost As New TabInfo()
            objTabHost = objTabController.GetTabByName("Host", -1, -1)
            If objTabHost <> Nothing Then
               tabs.Add(objTabHost)
            End If
       End If
    End If
End Sub
 

On your function BuildSiteMap2 you may added an extra condition as I listed above in Page Load by checking if the current user has a host role, we add a tab into the arraylist.

Please modify the code according to your needs.
I hope this help.

 

 
New Post
10/12/2008 11:21 AM
 

 Hi Jean,

I think that the problem is that you're using:

  Dim objTabs As New TabController
            Dim Tabs As ArrayList = objTabs.GetTabs(PortalID)

 

Instead, try this:

DotNetNuke.Entities.Portals.PortalController.GetCurrentPortalSettings().DesktopTabs

 

 
New Post
10/13/2008 6:55 PM
 

 

Thanks for the fast response both of you guys, both of the response are really working but the solution  provide by tony was the shortest one.

 Thanks a lot this kind of support is that make this product one of the most open source reliable at this moment

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Help Building a Menu For DNNHelp Building a Menu For DNN


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out