The only method provided by the DNN framework to get a module by ID also required a tab ID. What can I do if I don't have a tab ID?
views:
884answers:
3The GetModule method off of the DotNetNuke.Entities.Modules.ModuleController class will accept a "null" value for tab ID if you don't have a tab ID. That is, try the following:
new ModuleController().GetModule(moduleId, DotNetNuke.Common.Utilities.Null.NullInteger)
See also my blog post on the subject.
Brian, I just took a look at the code for GetModule(), and there isn't any specific VB code in the framework that checks for the tabid being null. What's interesting though is that the stored procedure that is part of the SqlDataProvider selects rows from the Modules view that have a matching moduleid, no matter what tabid is...
ALTER PROCEDURE [dbo].[dnn_GetModule]
@ModuleId int,
@TabId int
AS
SELECT *
FROM dbo.dnn_vw_Modules
WHERE ModuleId = @ModuleId
AND (TabId = @TabId or @TabId is null)
If I understand this correctly, this would return all the rows where moduleid is the one you specified, no matter if @tabid is null or not. That makes the @TabId rather pointless, don't you think?
One thing to watch out for when passing a null TabId to GetModule is that if you have a module that's installed on a number of different tabs, you'll be getting the first one back, so the values for TabId, TabModuleId and ModuleOrder will be based on that first instance, which may or may not be the instance you wanted.
HTH,
Don