You need to Register for free and Login to post a message in the forum.

Forum

Subject: Sites without menus - make menu visible to admins only
Prev Next
You are not authorized to post a reply.

Author Messages
andyb1979
Nuke Ace
Nuke Ace
Posts:56

10 May 2008 7:11 AM  
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!

Sites I made thanks to DNNCreative vids!
Rock Rhyme & Reason Fest | The Big Match
You are not authorized to post a reply.
Forums > DotNetNuke® > Quick Tips > Sites without menus - make menu visible to admins only



ActiveForums 3.7

Latest Forum Posts

RE: Server Application Unavailable from localhost by picoallen
OK, I've got things working better now. Not sure why though as I lost track while following all the ...
e-Survey? by mgordon
I need a module that will do the following:When a person comes to a specific page (recreation guide ...
Media Module *not* autostart? by PaulFlynn
Hi,I want to display a number of different .wmv files on a single page, but I'm concerned that the d...
RE: Event Module Scheduler? by mgordon
Never mind. I found out that you need to enable the Event Reminder in the actual Event that you are...
Event Module Scheduler? by mgordon
I have setup a Calendar of Events module on my page and have added events, no problem.  The main pro...
RE: Upgrading from 3.3.7 to 4.8.4 by puuri
I think I saw the answer to your last question on another thread real recently. If you go to the 'L...
Server Application Unavailable from localhost by picoallen
Hello,I have installed DotNetNuke and can open it from within Visual Web Designer, in which case it ...
RE: Upgrading from 3.3.7 to 4.8.4 by joannew
Hi, yes everything seems to be working fine. I get the following when viewing through Host Settings/...
RE: Database Access Error ! by nukedoubt
Got a fix........ 1)  Make sure that both the sqlDataProvider class and the DataProvider class are...
Database Access Error ! by nukedoubt
Error in Database Access : "The type initializer for 'MyCompany.Modules.Search.DataProvider' threw...
RE: Upgrading from 3.3.7 to 4.8.4 by jncraig
If everything "seems" to working normally, perhaps you can ignore it. It is possible that the other...
Upgrading from 3.3.7 to 4.8.4 by joannew
Hi,I've followed the upgrade procedures to upgrade from 3.3.7 to 4.8.4 and received the status repor...
RE: Regular restores to local machine by joannew
Thanks for getting back to me, just to let you know everything is working fine now, I can login as a...
RE: Create Bookmarks/Anchor Points/Page TOC by lb313
Thank you for your help Joe. Kind Regards Lisha Belbin
RE: Issue 22 - Login failed for user xxxx by picoallen
Thanks Joe, You put me on the right track there. Turns out that I had server authentication set t...
RE: How to speed DNN by mmcinulty
jump over to www.snapsis.com and get pageblaster. forum has alot of info about yslow and how to spee...
RE: Regular restores to local machine by jncraig
I've got more questions than answers ... Can you login as administrator and/or host? Can a logge...
RE: Refreshing Bl... IE by ollep
Thanks Guys!! Excelent support. I will - beleive it or not - be away from the computer for three...
Parent Portals and SSL by LucianV
Hi,I need to install and configure on our server several DNN parent portals (different domain names)...
RE: File Manager Upload (intermittent error) by dnnmq
Lee, your attention to this issue is truly appreciated because it's driving me nuts.js is included i...
DotNetNuke Modules
RSS Feeds