Give an unique id for every DNN Containers

Monday, October 12th, 2009 by George. Filed under DotNetNuke.

Inspired by Think of Design’s avoid span in module title and amount of requests including myself to have a unique id for every containers in DotNetNuke, I’ve came out with this simple solution to ease the designing works in DotNetNuke Skinning.

<!-- From thinkofdesign.com -->
<%@ Control language="vb" AutoEventWireup="false" Explicit="True" Inherits="DotNetNuke.UI.Containers.Container" %>
 <%@ Register TagPrefix="dnn" TagName="TITLE" Src="~/Admin/Containers/Title.ascx" %>
 <%@ Register TagPrefix="dnn" TagName="Actions" Src="~/Admin/Containers/Actions.ascx" %>
 
 <dnn:title runat="server" id="dnnTitle" visible="false" />
 <% Dim ModuleTitle As String = GetPortalModuleBase(dnnTitle).ModuleConfiguration.ModuleTitle %>
 
 <div class="common">
 <h3><%= ModuleTitle %></h3>
 <dnn:Actions runat="server" id="dnnActions" />
 <div id="ContentPane" runat="server" />
 </div> 

Using the same logic, we can retrieve the module id by modifying the DNN property code:

<% Dim ConModule As DotNetNuke.Entities.Modules.ModuleInfo = DotNetNuke.UI.Containers.Container.GetPortalModuleBase(Me).ModuleConfiguration %>
<div id="Container<%=ConModule.ModuleID %>" class="PekoOutterCon con180">

Theoretically, all you need to do is to change the .ModuleTitle to .ModuleID. Since CSS id cannot start with a number, you will need to add some word before calling out the ModuleID in the div.

However, you will find that if you logout from DNN, the module will failed to call out the correct ModuleID.

Thus, you will have to define that correct container and ModuleInfo.

Now you can change the individual container without interfering with other DNN Container.

Related posts:

  1. Guide to implement re-Captcha in DotNetNuke Modules without touching the source code.
  2. DotNetNuke Customizing your Login – PART 3
  3. How to modify DotNetNuke Login Page? The Easy Way.
  4. DotNetNuke Custom Error Page, 404 Page Not Found Redirection
  5. Making DotNetNuke Logo Link SEO Friendly!


Tags:

Leave a Reply