Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesGet TabName where a module is by the module controlkeyGet TabName where a module is by the module controlkey
Previous
 
Next
New Post
4/25/2011 1:46 PM
 

Hello,

I have scoured the internet for many hours on several occasions and cannot find the answer, which I find odd as I'd think this would be a very common need.

My Requirements:

  • Have 2 separate modules that can be seen in the control panel's module drop down so you can add module 1 to page 1 and module 2 to page 2.
  • Have a link on module 1 that takes you to page 2 and displays all modules on that page, not just module 2.
  • The functionality is just like the Blog Module's Recent Entries functionality (Except they didn't create it as a separate module control per point 1 above, but the linking works like I want. I tried looking at the source, but my lack of experience made it impossible for me to reverse engineer what was happening and how they coded it).

In the end, I think I just need to generate the link by using NavigateURL(TabID). The problem is how to get the TabID if all you know is the PortalID (can be determined at runtime) and ControlKey (can be hardcoded)? I've been looking at the GetModuleTabs Method (moduleID), but you need to know the Module ID...which you can't determine using just portalID and ControlKey. Also looked at ModuleControlController.GetModuleControlByControlKey(ControlKey, ModuleDefId), but you need to know the ModuleDefID, which again you can't determine.

So how can I get the tab ID that a module is installed on? I also guess there is an issue of the fact that it may be installed on more than one tab...but for my case, I can assume it would only be installed on one tab.

Thanks in advance,
Chad

 
New Post
4/25/2011 9:07 PM
 
Although there are many ways of coding this I find the easiest is to use the following method:

Public Function DotNetNuke.Entities.Modules.ModuleController.GetModules(ByVal PortalID As Integer) As ArrayList

to obtain an ArrayList of DotNetNuke.Entities.Modules.ModuleInfo objects representing all modules placed on pages of the Portal. I then iterate through the elements of the ArrayList to locate the desired module instance (s). Although the results of GetModules is cached this can be a rather processor intensive iteration in a large portal with many pages each containing many modules and should be done not in the Page_Load handler of Module A but rather in the Settings control for Module A allowing the administrator to select from a a drop-down list or other control which module B (s) will be associated with Module A. The selection (TabID and ModuleID) can then be saved in the ModuleSettings or TabModuleSettings for Module A.

Here's a quick bit of code (untested by similar to that I've used many times before) for you. Note that I have created a helper class ModuleInstance to contain the TabID, TabName, ModuleID, ModuleTitle of the desired modules instances in a form that can easily be bound to a drop-down list presenting the results of the search for the module(s)


 Public Class ModuleInstance
      Public Property TabID As Integer
      Public Property TabName As String
      Public Property ModuleTitle As String
      Public Property ModuleID As Integer

      Public Function Text() As String
        Return String.Format("Module {0} on page {1}", ModuleTitle, TabName)
      End Function

      Public Function Value() As String
        Return String.Format("{0}|{1}", ModuleID, TabID)
      End Function
End Class

Dim moduleInstances As New List(Of ModuleInstance)
Dim mc As New DotNetNuke.Entities.Modules.ModuleController
Dim portalModules As ArrayList = mc.GetModules(PortalId)

For Each mi As DotNetNuke.Entities.Modules.ModuleInfo In portalModules
        If mi.ModuleDefinition.FriendlyName = "MyModuleDefinitionName" Then
            Dim myModule As New ModuleInstance()
            With myModule
               .TabID = mi.TabID
               .TabName = mi.ParentTab.TabName
               .ModuleTitle = mi.ModuleTitle
               .ModuleID = mi.ModuleID
            End With
            moduleInstances.Add(myModule)
        End If
Next

Note that if you are planning to use NavigateUrl or EditUrl to build the link to Module B you will need both the ModuleID and ControlKey (which can be hardcoded) if Module B is to display one of its module controls and not the default view control which will not have a ControlKey.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
New Post
4/25/2011 9:47 PM
 
Bill,

Thanks again! This put me in the right direction and I think I have it working now. But I didn't iterate through the collection, I just looked up the module definition by Friendly Name to begin with. Is there anything wrong with this approach?

Public Function getdynoLink(ByVal strNodePath As String) As String


Dim strURL As String

Dim mC As New ModuleController
Dim mi As DotNetNuke.Entities.Modules.ModuleInfo

mi = mC.GetModuleByDefinition(0, "Module Control Friendly Name")
strURL = NavigateURL(mi.TabID)
Return strURL

End Function

Thanks,
Chad
 
New Post
4/25/2011 9:50 PM
 
Ooops, don't hardcode the portalID like I did in that example...use Portalsettings.PortalId instead to get current portal ID....
 
New Post
4/25/2011 10:13 PM
 
Chad,

That will work as long as you can be sure that there will always be one and only one instance of Module B on the portal. I would also suggest checking that GetModuleByDefinition returns a non-null ModuleInfo object before accessing its TabID property and handling this possibility gracefully.

Bill, WESNet Designs
Team Lead - DotNetNuke Gallery Module Project (Not Actively Being Developed)
Extensions Forge Projects . . .
Current: UserExport, ContentDeJour, ePrayer, DNN NewsTicker, By Invitation
Coming Soon: FRBO-For Rent By Owner
 
Previous
 
Next
HomeHomeDevelopment and...Development and...Building ExtensionsBuilding ExtensionsModulesModulesGet TabName where a module is by the module controlkeyGet TabName where a module is by the module controlkey


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out