<

Improve company productivity with a Business Account.Sign Up

x

SkinSrc and ContainerSrc Snippet

Published on
9,406 Points
3,406 Views
Last Modified:
Approved
Community Pick
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need to specify the SkinSrc and ContainerSrc in the URL.  This little chunk of code provides just that checking the full hierarchy for overrides:

Protected Function GetSkinContainerSrc() As String

    Dim strReturn As String = String.Empty
    Dim objTabs As New TabController()
    Dim objTab As DotNetNuke.Entities.Tabs.TabInfo = objTabs.GetTab(Me.TabId)

    'Get the skin source
    'Check the tab settings first.
    Dim strSkin As String = objTab.SkinSrc

    If strSkin = String.Empty Then
        'Not in the tab settings, check the portal
        strSkin = PortalSettings.PortalSkin.SkinSrc
    End If

    'Cleanup the string if it doesn't have the global/local information.
    If strSkin <> String.Empty Then
        If strSkin.IndexOf("/Portals/") >= 0 Then
            If strSkin.IndexOf("/Portals/_default/") >= 0 Then
                strSkin = "[G]" & strSkin.Substring(strSkin.IndexOf("/Skins/") + 1)
            Else
                strSkin = "[L]" & strSkin.Substring(strSkin.IndexOf("/Skins/") + 1)
            End If
        End If

        strReturn += "&SkinSrc=" & Server.UrlEncode(strSkin.Replace(".ascx", String.Empty))
    End If

    'Get the container source
    'Check the module settings for the container first.
    Dim strContainer As String = Me.ModuleConfiguration.ContainerSrc

    If strContainer = String.Empty Then
        'Not in the module, check the tab.
        strContainer = objTab.ContainerSrc

        If strContainer = String.Empty Then
            'Not in the tab, check the portal
            strContainer = PortalSettings.PortalContainer.SkinSrc
        End If
    End If

    'Cleanup the string if it doesn't have the global/local information.
    If strContainer <> String.Empty Then
        If strContainer.IndexOf("/Portals/") >= 0 Then
            If strContainer.IndexOf("/Portals/_default/") >= 0 Then
                strContainer = "[G]" & strContainer.Substring(strContainer.IndexOf("/Containers/") + 1)
            Else
                strContainer = "[L]" & strContainer.Substring(strContainer.IndexOf("/Containers/") + 1)
            End If
        End If

        strReturn += "&ContainerSrc=" & Server.UrlEncode(strContainer.Replace(".ascx", String.Empty))
    End If

    Return strReturn

End Function

Open in new window


This code will start at the Tab and then move to the Portal for the Skin path.  For the container it moves through the current container up through the Tab and Portal.  The code handles adding/removing the appropriate Local or Global variations to the string if they aren't found (different locations store these strings differently, very annoying).

The resulting string will be formatted like this:
&SkinSrc=[Relevant Skin Path]&ContainerSrc=[Relevant Container Path]

This string can then be added to your control URL to display the new control within the current page skin and container.  This will keep DNN from displaying the current Admin only page skin or container.  Your users won't be as jarred by a change in visual look and feel to the site.

The only real alternative when faced with this issue is to use an admin skin that matches your design and functionality.  This can be very limiting since admin skins in general are nice to keep addition menu features enabled for ease of navigation while administering the site.  This issue was very prevalent in pre DNN 5.0 versions where I have used this function extensively.  In post DNN 5.0 control swapping has become much more user friendly; however this method can still come into use for storing and retrieving custom skins for individual controls.

One simple function to handle a rather mundane task, but if you are swapping a control and come across this issue hopefully this will save you a few stressful hours.
0
Comment
Author:wolfie62676
0 Comments

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Join & Write a Comment

In the video, one can understand the process of resizing images in single or bulk. Kernel Bulk Image Resizer is an easy to use tool for resizing large number of images. One can add and resize multiple images with this tool in single go. The video sh…
Watch the software video of Kernel Import PST to Office 365 tools which can easily import PST and OST files to Office 365 for bulk mailboxes. The process of migration is simple and user can map source and destination mailboxes and easily import data…

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month