Small width layout Medium width layout Maximum width layout Small text Medium text Large text
     Search
Downloads Downloads Directory Directory Forums Forums Forge Forge Blogs Blogs        Marketplace Marketplace Careers Program Careers
Community › Forums Register  |  

AspDotNetStoreFront
  Need Help?  
Professional technical support for DotNetNuke is available from DotNetNuke Corporation.
 


  Ads  
Aspose - The .NET & Java component publisher
 


  Sponsors  

Meet Our Sponsors

.: CounterSoft :.
telerik
ExactTarget email software solutions
Merak Mail Server
WebSecureStores -- ASP.NET & DotNetNuke Hosting Solutions
FCKeditor Project
 


DotNetNuke Forums
 
  Forum  General DotNetN...  Extend It! ( Pr...  How to get the ModuleId from another Module
Previous Previous
 
Next Next
New Post 11/27/2007 5:34 PM
Online now... William Severance
788 posts
www.wesnetdesigns.com
7th Ranked






Re: How to get the ModuleId from another Module 

Actually that does not quite get you the desired ModuleID, only the DesktopModuleID which has a whole different purpose.  Here are several points to keep in mind when getting information about a module:

1. A module definition's FriendlyName can be changed on the Host-->ModuleDefinitions page. Several DNN versions back, a new module defintion property was added, the ModuleName. This is not supposed to change - and, in fact, recent DNN versions dis-able this the text box for ModuleName on the ModuleDefinitions page.  So, it is much safer to search for a module definition based on ModuleName rather than FriendlyName.  The DesktopModuleController now provides the following method:

Function GetDesktopModuleByModuleName(ByVal ModuleName As String) As DesktopModuleInfo

The method which you used indirectly calls GetDesktopModuleByFriendlyName which uses the FriendlyName rather than ModuleName for its search.

2. For a given PortalID, there can be one or many module instances all having the same FriendlyName or ModuleName located on one or many pages (tabs).  Think how many times the core Html/Text module appears on a page or portal.

3. Multiple occurances of modules having the same FriendlyName or ModuleName may have different ModuleID's (when placed with the Add Module command) or with the SAME ModuleID (but diferent TabModuleID's) when placed with the Add Existing Module command.

If I may assume that your requirement is to obtain the ModuleID for the instance of a module which you know occurs once and only once in the Portal then the following will work provided you can trust the FriendlyName not to have changed from its installation:

Function GetModuleID(ByVal TargetModuleFriendlyName As String) As Integer
   Dim mc As New ModuleController
   Dim mi As ModuleInfo = mc.GetModuleByDefinition(PortalId, TargetModuleFriendlyName)
   If mi Is Nothing Then
       Return -1
   Else
       Return mi.ModuleID
   End If
End Function

A better method (and a variation of the one that I actually use which returns multiple matches in a dictionary object with ModuleTitle as Key and ModuleInfo object as Value)  allows you to specify the TabID on which the module instance is located and the ModuleName rather than FriendlyName:

Function GetModuleID(ByVal TargetTabID As Integer, ByVal TargetModuleName As String) As Integer
    Dim dmc As New DesktopModuleController
    Dim dmi As DesktopModuleInfo = dmc.GetDesktopModuleByModuleName(TargetModuleName)
    If Not dmi Is Nothing Then
         Dim mc As New ModuleController
         Dim modList As ArrayList = mc.GetModulesByDefinition(PortalId, dmi.FriendlyName)
         For Each mi As ModuleInfo In modList
               If mi.TabID = TargetTabID Then Return mi.ModuleID
         Next
    End If
    Return -1
End Function

Note that this last method could still return only the first of potentially multiple matches with the same TabID and ModuleID but different TabModuleID's.


Bill, WESNet Designs
 
New Post 11/28/2007 8:04 AM
User is offline Pril
142 posts
9th Ranked


Re: How to get the ModuleId from another Module 

I have more functions for similar cases. One is recursive and search modules on page by module header text and some others.

In your case is much more simple to query database. All is there and data are well structured so is easy to get id.

Kind regards,

Primoz

 
New Post 11/28/2007 11:22 AM
User is offline Eric Piraux
19 posts
10th Ranked


Re: How to get the ModuleId from another Module 

Thank you for your posts guys.

I'm still wondering where to get detailed explaination to understand what's is the difference between Module and Tab ?

 

In any way, I understand that both solutions (helper class and direct query) are workaround to implement missing features in the framework.

To develop robust application, not only content management, but for instance in my case a tool to manage a school, some efforts should still be done to provide helpers in the communication between modules, controls...

In any case DNN is really promising, I like it.

 

 
Previous Previous
 
Next Next
  Forum  General DotNetN...  Extend It! ( Pr...  How to get the ModuleId from another Module
 


Forum Policy

These Discussion Forums are dedicated to the discussion of the DotNetNuke Web Application Framework.

For the benefit of the community and to protect the integrity of the project, 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 DotNetNuke.
2. Discussion or promotion of DotNetNuke product releases under a different brand name are strictly prohibited.
3. No Flaming or Trolling.
4. No Profanity, Racism, or Prejudice.
5. Site Moderators have the final word on approving/removing a thread or post or comment.
6. English language posting only, please.

 


DotNetNuke Training by Engage Software
Specializing in customized training, architecture and module solutions for large scale implementations lead by DNN Core Team Member Christopher Hammond.
engagesoftware.com
Smart-Thinker
DNN Modules for Social Networks for as low as $69 for 6 modules! We also maintain the DotNetNuke Directory - http://DNNDir.com
www.smart-thinker.com
DNN Photo Gallery
Complete Photo Gallery Management!
www.dnnPhotoGallery.com

DotNetNuke Corporation   Terms Of Use  Privacy Statement
DotNetNuke®, DNN®, and the DotNetNuke logo are trademarks of DotNetNuke Corporation
Hosted by MaximumASP