I'm developing a simple two-page site at www.bigmatch.org.uk. Because its so simple, It doesn't need a menu. However menu's are extremely useful when administrating the site.
What I wanted was a hidden menu that was visible to admins only. A bit of googling and I came up with this:
In your skin.ascx file (sorry, this technique only works with ascx skins), add an ASP.NET panel to hold your menu:
<asp:panel runat="server" visible="false" id="pnlMenuArea" >
<snapsis:navmenu class="adminHostList" id="NavMenu1" level="0-1" type="SelectList" runat="server"/>
<!--
<!--< / asp:panel >
Make sure the panel visibility is set to false and you add an ID. Here I've used the Snapsis Navmenu, but I imagine you can use any skin object menu type. Next in the code-behind for your ascx file (If you don't have a code behind, create one!) add the following code (in C#):
// check if the current user is an admin
if (PortalSecurity.IsInRole(PortalSettings.AdministratorRoleId.ToString()) == true ||
PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString()) == true)
{
// If so, display the admin menu area
this.pnlMenuArea.Visible = true;
}
else
{
// If not, hide the admin menu area
pnlMenuArea.Visible = false;
}
Or, in visual basic:
If (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleId.ToString) = True Or _
PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString) = True) Then
Me.pnlMenuArea.Visible = True
Else
Me.pnlMenuArea.Visible = False
End If
Et voila! Now your menu is invisible to visitors, but visible when logged in as an admin.
Happy coding!