tags:

views:

32

answers:

1

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.

+2  A: 

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
        ....
Bill
Bill, so your container file has a code-behind file? Just want to confirm. Didn't know that was possible... but it makes sense
hamlin11
@hamlin - yes. our skin/container is a mess of ascx and ascx.vb files, although the code I sent was from \admin\containers, so it may be part of the standard DNN4 package.
Bill