DotNetNuke Modules – Finding The Page a Module is On
Last week we talked a bit about Inter Module Communication, the ability of one module to notify another module on the page that something needs to happen without requiring a post back. The other need you may have is something I refer to as Cross Page Communication. This is not a DotNetNuke term, I just made it up today.
Here’s the problem. In some cases, you may have a module that you’ve placed on a page that should only ever be on one page. In my case, this was the checkout module. I needed some way of retrieving the page that that module was on so that I could create a hyperlink to that page from my modules that displayed my products and my “mini cart” module that displayed a summary of items in the shopping cart.
Here’s how I did it:
// Find the tab the module specified by //friendlyName, is on. // ModuleController is in: // DotNetNuke.Entities.Modules namespace ModuleController moduleController = new ModuleController(); // User the friendlyName to find the moduleID int myModuleDefId = Globals.GetDesktopModuleByName(friendlyName) .DesktopModuleID; // Get all the tabs available for this portal. ArrayList tabs = (new TabController()) .GetTabs(portalId); foreach (TabInfo ti in tabs) { // For each page, find all the modules on the page Dictionary<int,ModuleInfo> modules = moduleController.GetTabModules( ti.TabID); foreach (ModuleInfo mi in modules.Values) { // If the module on the page is the module we // are looking for, return it. if (mi.DesktopModuleID == myModuleDefId) { return ti.TabID; } } }
Other post in DotNetNuke - Module Development
- Creating DotNetNuke Modules - May 20th, 2008
- Creating DNN Modules - The Tools - May 22nd, 2008
- DotNetNuke Modules - Foundational Concepts - May 26th, 2008
- DotNetNuke Modules - Install DNN into VS 2008 - May 27th, 2008
- DotNetNuke Modules - Creating Base Modules - May 28th, 2008
- DotNetNuke Modules - Registering Your Module - May 29th, 2008
- DotNetNuke Modules - Where Stuff Shows Up - June 3rd, 2008
- DotNetNuke Modules - Benefits of Architecture - June 4th, 2008
- DotNetNuke Modules - Anatomy of the View - June 9th, 2008
- DotNetNuke Modules - Adding Actions - June 11th, 2008
- DotNetNuke Modules - DNN Controls - Label - June 18th, 2008
- DotNetNuke - Internationalization - June 25th, 2008
- DotNetNuke Modules - Internationalization (part 2) - June 30th, 2008
- DotNetNuke Modules - Labels w/ no Help - July 9th, 2008
- DotNetNuke Modules - LinkButtons - July 14th, 2008
- DotNetNuke Modules - Collapsible Panels - July 16th, 2008
- DotNetNuke - The Data Layer - Installing CodeSmith - July 22nd, 2008
- DotNetNuke - Modules - Creating The Tables - July 24th, 2008
- DotNetNuke - Modules - Creating Stored Procs - July 29th, 2008
- DotNetNuke - Modules - Portal Specific Modules - July 31st, 2008
- DotNetNuke Modules - Data Access Layer - August 5th, 2008
- DotNetNuke Modules - Data Access Layer - August 7th, 2008
- DotNetNuke - Data Access Layer Alternative - August 12th, 2008
- DotNetNuke - Modules - Linking within the module - August 14th, 2008
- DotNetNuke - Make Your Module Searchable - August 19th, 2008
- DotNetNuke Modules - Making Content Portable - August 25th, 2008
- DotNetNuke Modules - Exceptions the DNN Way - September 2nd, 2008
- DotNetNuke Modules - PortalModuleBase - September 4th, 2008
- DotNetNuke Modules - Inter Module Communication - September 9th, 2008
- DotNetNuke Modules - Finding The Page a Module is On - September 15th, 2008
- DotNetNuke Modules - Caching - September 17th, 2008
- DotNetNuke Modules - Module Settings - September 22nd, 2008
- DotNetNuke Modules - Retrieving Settings - September 24th, 2008
- DotNetNuke Modules - Advanced Architecture - October 20th, 2008
- DotNetNuke Modules - Creating the PA - October 30th, 2008
- DotNetNuke Modules - Automating the PA - November 5th, 2008
- DotNetNuke - FileUploadControl Danger! - February 26th, 2009
- DotNetNuke SecurityException AspnetHostingPermission - October 14th, 2009
- Changing an Existing DNN Module - March 4th, 2010
Other Related Items:
Universal Learning Bypass ModuleUniversal Learning Bypass Module, works on all vehicles equipped with a factory anti-theft system, Automatically learns resistance values without setting dip switches or using a volt meter.
Floating Leaf and Debris Pond Net - 7 ft. x 10 ft.Protect your fish from predators and keep the autumn leaves out with Supreme Floating Pond Netting. Tough, durable netting floats on surface for easy set up and removal.











The tab iteration on a portal with thousands of pages will be quite expensive. A better solution from an architectural point is that the Checkout module saves its location to the DB, either by way of a module setting or a specific field in a module configuration table. In that manner, your other modules can retrieve this directly.
Yes, it is (was).
As is common with most of my post I only gave you the specifics on how to retrieve the information. I did not tell you what to do with it.
IF you need to find out where a module is, this is how you do it. And even if you use this method, you wouldn’t retrieve it every time you hit the page because even on a relatively small site, you’d get killed on performance.
Will it be better if we do this?
Dim objModuleController As DotNetNuke.Entities.Modules.ModuleController = New ModuleController()
Dim moduleList As ArrayList = objModuleController.GetModulesByDefinition(PortalId, moduleName)
For Each modInfo As ModuleInfo In moduleList
‘Return modInfo.TabID
Next
Private Function GetFirstModuleTabId(ByVal PortalId As Integer, ByVal moduleName As String) As Integer
Dim objModuleController As DotNetNuke.Entities.Modules.ModuleController = New ModuleController()
Dim moduleList As ArrayList = objModuleController.GetModulesByDefinition(PortalId, moduleName)
For Each modInfo As ModuleInfo In moduleList
Return modInfo.TabID
Next
Return 0
End Function
Without running I’d have to say no only because it looks like really old syntax if it worked at all.