Brian Webster
Brian Webster

Reputation: 30865

dotnetnuke - How do I create a container skin so that its title is only shown in edit and layout modes?

How do I create a container skin so that its title is only shown in edit and layout modes?

I know I can set show-container: false in the page settings... but I'd really rather not have to set this for all pages on the entire site that my container skin is installed on.

Upvotes: 0

Views: 1578

Answers (1)

Bill
Bill

Reputation: 4585

This is DNN4, and I didn't write it, but here is the code ripped from our container that does just this. I will let you slog thru and decide which parts you don't need:

Here is the line from the container's ascx file...

<DNN:DNNToolBar id="tbEIPTitle" runat="server" CssClass="eipbackimg" ReuseToolbar="true">...

and code from the ascx.vb file...

 Private Function CanEditModule() As Boolean
     Dim blnCanEdit As Boolean = False
     Dim objModule As Entities.Modules.PortalModuleBase = Container.GetPortalModuleBase(Me)
     If (Not objModule Is Nothing) AndAlso (objModule.ModuleId > Null.NullInteger) Then
         blnCanEdit = (PortalSettings.UserMode = PortalSettings.Mode.Edit) 
             AndAlso (PortalSecurity.IsInRoles(PortalSettings.AdministratorRoleName)
             OrElse PortalSecurity.IsInRoles(PortalSettings.ActiveTab.AdministratorRoles.ToString))
             AndAlso (IsAdminControl() = False) 
             AndAlso (PortalSettings.ActiveTab.IsAdminTab = False)
      End If
      Return blnCanEdit
 End Function

and...

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    ...
    If CanEditModule() = False OrElse Entities.Portals.PortalSettings.GetSiteSetting(objPortalModule.PortalId, "InlineEditorEnabled") = "False" Then
        lblTitle.EditEnabled = False
        tbEIPTitle.Visible = False
        ....

Upvotes: 2

Related Questions