Saturday, August 16, 2008

Hiding Sections from Unauthenticated Users in DotNetNuke Skins and DNN Skin Conversions

A lot of times, when creating a DotNetNuke skin, I find the need to hide a certain link, text or skinobject in my dnn skin to users that are not logged in. There is a super-simple way to do this, if you add in a little server side code into your skin conversion.

For this example, I wanted to hide the User DotNetNuke skin object. This is for an e-commerce website, so it made sense to only have users register during the checkout process and hide the "Register" link that shows up to unauthenticated users.

<% If Request.IsAuthenticated Then%>
<%dnn:user id="dnUser" runat="server"%>
<%% End If%%>

The way this works is that anything within that server-side if statement is displayed at runtime if the user is logged in.

You could also switch it so that you have a section that only shows up in your skin if the user if not authenticated by changing it to

<% If Not Request.IsAuthenticated Then%>
<%span class="NormalRed"%> You're Not Logged In!<%/span%>
<%% End If%%>

If you're interested in creating custom role access for sections of skins, checkout my last blog post here: http://dotnetnuke-skin.blogspot.com/2008/08/creating-custom-role-to-display-admin.html

Happy Nuking,
Ryan Morgan
Arrow Consulting & Design


Arrow Consulting & Design is a consulting firm based in West Palm Beach, Florida specializing in DotNetNuke, ASP.NET, SQL and WPF Development with a portfolio filled with local, national, government and global enterprise clients.

Case Studies: Click Here
Main Corporate Site: http://www.arrowdesigns.com/default.aspx?utm_source=blogspot
DotNetNuke Community Site: http://www.arrownuke.com/default.aspx?utm_source=blogspot
Consulting Inquiries: Click Here
Skin Design/Conversion: Click Here
DotNetNuke Portfolio: Click Here

2 comments:

Shasing19 said...

Your post was great and I like it. You did an amazing piece. Big thanks and keep sharing.


web design Philippines

Unknown said...

In the dotnet nuke security is very good and that hiding section works is great. Good stuff about it

Hire Our Dedicated Professional Dotnet Nuke Web Developer India