Sunday, March 13, 2005
by Nik Kalyani
Sunday, March 13, 2005 1:23:21 PM (Pacific Standard Time, UTC-08:00)

nokiko asks:

I am working on some new containers and dnn enhancements. I want to know in my container which moduleid is loaded so lets say i have an ascx container and in there i have the following:

<div id=''mod_<% functiontogetmoduleidhere'">rest of container ...</div>

Is there a function or another way that in an ascx container I would know which moduleid is loaded in there.

So that way lets say i have 2 modules one one page and i want the ascx container to render

<div id="mod_36">content here</div>
<div id="mod_37">content here</div>

i would need this to imge replace techniques on my h3 tags for instance

#mod_36 h3 { background:url(announcements.gif) }
#mod_37 h3 { background:url(events.gif)}

Nik’s answer:

That’s an excellent question nokiko. In DotNetNuke 3.x, the Container class has a public, static method called GetPortalModuleBase(). This method requires one parameter — a usercontrol that is present in the container. With this knowledge, it is easy to figure out a solution. For example, most of the default DNN containers have a title defined using: <dnn:TITLE runat="server" id="dnnTITLE" />. In any of these containers, you can add the following line to display the ModuleId of the module present in the container:

<%= DotNetNuke.UI.Containers.Container.GetPortalModuleBase(dnnTitle).ModuleId.ToString() %>

You can also use the same technique to display any other Portal, Tab, Module or User property to customize the appearance of containers dynamically:

<%= DotNetNuke.UI.Containers.Container.GetPortalModuleBase(dnnTitle).PortalSettings.PortalName %>
<%= DotNetNuke.UI.Containers.Container.GetPortalModuleBase(dnnTitle).PortalSettings.ActiveTab.TabName %>
<%= DotNetNuke.UI.Containers.Container.GetPortalModuleBase(dnnTitle).ModuleConfiguration.ModuleTitle %>
<%= DotNetNuke.UI.Containers.Container.GetPortalModuleBase(dnnTitle).UserInfo.FirstName %>

If you don’t have a need for the DNN Title control in your container, that’s OK. You can add it anyway with an attribute of “Visible=false”. It is possible to achieve this result without using any skin control, however it requires a little more code and is not worth the effort in most situations.

 

Sunday, March 13, 2005 2:02:55 PM (Pacific Standard Time, UTC-08:00)
Nik

I knew this was possible, now this opens up a bunch of new css and clientside functionality I can now try out

thanks

Armand aka Nokiko
Armand
Monday, May 16, 2005 2:13:02 AM (Pacific Standard Time, UTC-08:00)
hi

thanks have been using the modulebase now quite extensively, but how would I go about getting page id or pagename or pagedescription the same way.

Isa there a way for that one too?
Armand
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, i, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview
RSS feed
Search and Links
Bling

View Nik Kalyani's profile on LinkedIn

Contact me: nik*kalyani.com (replace "*")

TechBubble
www.flickr.com
This is a Flickr badge showing public photos from techbubble. Make your own badge here.
Statistics
Total Posts: 216
This Year: 34
This Month: 2
This Week: 0
Comments: 238
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2008
Nik Kalyani
Sign In
All Content © 2008, Nik Kalyani