One of the great features of DNN 6 is the new and improved toolbar. I think this really replaces the need for using the Oliver Hine toolbar, which is great for DNN 5. Most of the capabilities of Oliver's toolbar have been duplicated in the stock DNN 6 toolbar. There is one setting that is sorely missing, however. The ability to chose the module container when adding a module to the page.

 

Luckily, it's pretty easy to add in. Essentially, you can copy the functionality out of the ModuleSettings control (root/Modules/moduleSettings.ascx). Hopefully this quick & dirty hack will tide us over until the enhancement makes it's way into the core.


 

What to modify:

Navigate to root/Admin/ControlPanel

There you will edit AddModule.ascx/AddModule.ascx.cs

 

AddModule.ascx

Add in a new dropdown for the Add Module section to populate with containers.


<div class="dnnClear">
    <asp:Label ID="Label3" runat="server" ResourceKey="Container" AssociatedControlID="ContainerLst" Text="Container" />
    <asp:DropDownList ID="ContainerLst" runat="server" AutoPostBack="true" DataTextField="Key" DataValueField="Value" />
</div>


 

I put this after the pane list dropdown. Note: I made the ResourceKey =  Container, but did not modify the Resources file. I don't need localization, but you may want to add that if you do.

 

AddModule.ascx.cs

Add Usings

At the top of the cs file, you will have to add two entries to the using section:

using DotNetNuke.UI.Skins;
using DotNetNuke.UI.Skins.Controls;


Bind Containers

You'll have to add a method to bind the list of Containers. In the Methods region, add a method to do so:


private void LoadContainers()
        {
            var portalController = new PortalController();
            var portal = portalController.GetPortal(PortalSettings.Current.PortalId);
            var containers = SkinController.GetSkins(portal, SkinController.RootContainer, SkinScope.Site)
                                    .ToDictionary(skin => skin.Key, skin => skin.Value);
 
            ContainerLst.DataSource = containers;
            ContainerLst.DataBind();
            ContainerLst.InsertItem(0, "<" + Localization.GetString("None_Specified") + ">", "");
            
        }

 

Note: there is an option called SkinScope that allows to you select containers from the site, host or both levels. I rarely use host containers so I made this site level only.

 



 Now, add the new method to the LoadAllLists() method

 


private void LoadAllLists()
        {
            LoadCategoryList();
            LoadPageList();
            LoadModuleList();
            LoadVisibilityList();
            LoadPaneList();
            LoadPositionList();
            LoadPaneModulesList();
            LoadContainers();
        }


Modify DoAddNewModule

Next, we have to save the container settings. To do this, modify the method:  DoAddNewModule

 


Notice we added a string parameter called "container"

private static void DoAddNewModule(string title, int desktopModuleId, string paneName, int position, int permissionType, string align, string container)


 

 ... farther down, we add the container to the object

 


objModule.PortalID = PortalSettings.Current.PortalId;
               
...
objModule.ContainerSrc = container;



Pass in the new parameter

Do a search for DoAddNewModule and add in the selected Container.

 

DoAddNewModule(Title.Text, moduleLstID, PaneLst.SelectedValue, position, permissionType, "", ContainerLst.SelectedValue);


Yes, it is hackish and crude. But it is sufficient as a stop gap until DNN adds it in as an enhancement.