Follow me on twitter @yodasmydad
Ahhhh #Fringe can't finish like that!! Latest Tweet:

Hey I'm Lee. My blog was put up to house my strange thoughts, ramblings, nuggets of information I can refer back to and document my learning curves on new dev stuff like Umbraco v5 and other .NET related things.

All thoughts and comments on here are my own, and in no way reflect my employer - I also take no responsibility for spelling, grammar or terminology, so read at your own risk!

Blogs I Read

Sites I Like

Nested LoginView For Admin Navigation

In my latest personal Umbraco project I had the need for a persistent admin navigation when a Member was logged in, but on this project I had two different Member types so needed to show a different admin menu based on the Role the user was assigned to.

Sounds simple enough to do with a LoginView and it is, but this admin menu has a login status regardless of role and also some other bits above and below the menus I won't go into that would be visible regardless of role too (And I didn't want to appear on the page if the user wasn't logged in).

So I came up with a little idea of nesting LoginViews, I didn't know you could do this but it worked a treat for what I needed.  I have just added the below into my Master.master and it works perfectly with the Umbraco membership (The code below is trimmed down compared to the actual code in my project to show the concept).

<asp:LoginView ID="lvAdminPanel" runat="server">
<LoggedInTemplate>
   <div id="adminpanel">
    <div id="adminpanelstatus">
        <p>
            <span class="status"><umbraco:Macro Alias="LoginStatus" runat="server"></umbraco:Macro></span>
            Your Admin...
        </p>
    </div>    
    <div id="adminpanelmenu">

        <asp:LoginView ID="lvAdminPanelMenu" runat="server">
        <RoleGroups>
            <asp:RoleGroup Roles="JobSeeker">
                <ContentTemplate>
                  <umbraco:Macro ID="JobSeekerMacro" source="1174" Alias="SeekerNavigation" runat="server"></umbraco:Macro>                                    
                </ContentTemplate>
            </asp:RoleGroup>
            <asp:RoleGroup Roles="JobPoster">
                <ContentTemplate>
                  <umbraco:Macro ID="JobPosterMacro" source="1179" Alias="PosterNavigation" runat="server"></umbraco:Macro>
                </ContentTemplate>
            </asp:RoleGroup>
        </RoleGroups>
        </asp:LoginView>
        
    </div>
  </div>
</LoggedInTemplate>
</asp:LoginView>

As you can see I just dump the status in the first LoginView and then use the <RoleGroups> in the nested LoginView to display a custom XSLT Navigation macro for each role. I know this isn't ground breaking, but I found nesting the LoginViews worked really well for me in a multi Member Type scenario :)

Back to top