Adding "Check for Updates" to your module

To add a "Check for Updates" action menu item to your DotNetNuke module, use the code below.  The code elements you must add from the samples below are:

  1. Add a menu item to the actions menu.  For DotNetNuke 2.1.2 modules, add the line of code below to your Page_Init function.  For DNN 3 and 4 modules, implement the Implements DotNetNuke.Entities.Modules.IActionable interface and add the line of code below to your ModuleActions function.
  2. Add the supporting function GetDNNUpdatePortalURL.  The SourceModuleName argument to GetDNNUpdatePortalURL is used to pass to the DNN Update module (or dnnupdate.com website if the module is not installed) in order to "personalize" messages shown to the user by including your module name in the text.

Note:  You don't have to add this code to your modules in order to make updates available with DNNUpdate.  Use of the code samples below is completely optional.

There are code samples below for both DotNetNuke 2.1.2 (click here) and DotNetNuke 3 & 4 (click here).


     
Code Sample for DotNetNuke 2.1.2

Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
  InitializeComponent()

  ' 1.  Add a menu item to the actions menu
  MyBase.Actions.Add( _           
    GetNextActionID, _
    "Check for Updates", _
    "", _
   
URL:=GetCheckUpdatesURL("your module"), _
    secure:=SecurityAccessLevel.Host, _
    Visible:=True)
End Sub

Private Function GetCheckUpdatesURL(ByVal SourceModuleName As String) As String
  ' 2.  This function figures out whether you already have DNN Update installed,

  ' if not, it redirects the user to the dnnupdate website

  Dim objTab As DotNetNuke.TabInfo

  With New DotNetNuke.TabController
    objTab = .GetTabByName("DNN Update")
  End With

  If objTab Is Nothing Then
    ' direct to
www.dnnupdate.com
    Return "http://www.dnnupdate.com/module-intro.content?module=" & _
           SourceModuleName
  Else
    Return DotNetNuke.glbDefaultPage & "?tabid=" & _

           objTab.TabID.ToString & "&module=" & SourceModuleName
  End If
End Function


     
Code Sample for DotNetNuke 3 & 4

Public ReadOnly Property ModuleActions() As DotNetNuke.Entities.Modules.Actions.ModuleActionCollection Implements DotNetNuke.Entities.Modules.IActionable.ModuleActions
  Get
    ' 1.  Add a menu item to the actions menu
    Dim Actions As New DotNetNuke.Entities.Modules.Actions.ModuleActionCollection
    Actions.Add(GetNextActionID, _
                "Check for Updates", _
                "", _
                "", _
                "", _
                GetCheckUpdatesURL("your module name"), _
                False, _
                DotNetNuke.Security.SecurityAccessLevel.Host, _
                True, _
                True)
    Return Actions
  End Get
End Property


Private Function GetCheckUpdatesURL(ByVal SourceModuleName As String) As String
  ' 2.  This function figures out whether you already have DNN Update installed,

  ' if not, it redirects the user to the dnnupdate website

  Dim objTab As DotNetNuke.Entities.Tabs.TabInfo

  With New DotNetNuke.Entities.Tabs.TabController
    objTab = .GetTabByName("DNN Update", DotNetNuke.Common.Utilities.Null.NullInteger)
  End With

  If objTab Is Nothing Then
    ' direct to
www.dnnupdate.com
    Return "http://www.dnnupdate.com/module-intro.content?module=" & _
           SourceModuleName
  Else
   
Return objTab.FullUrl & IIf(objTab.FullUrl.IndexOf("?") >= 0, "&", "?") & _
           "module=" & SourceModuleName
  End If
End Function


     
Copyright 2005-2006 Inventua Pty Ltd. All Rights Reserved. Privacy Policy