DotNetNuke Modules – Adding Actions

Monday, we took a look at the Anatomy of the View component and touched on the ModuleActions property. Today, we are going to dig into the Actions.Add() function a little deeper.


The Add() function has the following signature

public ModuleAction Add(int ID,
   string Title,
   string CmdName,
   string CmdArg,
   string Icon,
   string Url,
   bool UseActionEvent,
   SecurityAccessLevel Secure,
   bool Visible,
   bool NewWindow);
Parameter Description
ID The ID is used to generate a unique ID for the action. You can have DotNetNuke generate this for you by calling GetNextActionID() for that parameter.
Title This is the text that will display for the user. You should store this text in a RESX file and retrieve it with the following code:

Localization.GetString(LocalizationKey,
                      this.LocalResourceFile)

For LocalizationKey, you can used the built in keys located in DotNetNuke.Entities.Modules.Actions:

public class ModuleActionType
{
  public const string AddContent =     "AddContent.Action";
  public const string ClearCache =     "ClearCache.Action";
  public const string ContentOptions =     "ContentOptions.Action";
  public const string DeleteModule =     "DeleteModule.Action";
  public const string EditContent =     "EditContent.Action";
  public const string ExportModule =     "ExportModule.Action";
  public const string HelpText =     "ModuleHelp.Text";
  public const string ImportModule =     "ImportModule.Action";
  public const string ModuleHelp =     "ModuleHelp.Action";
  public const string ModuleSettings =     "ModuleSettings.Action";
  public const string MoveBottom =     "MoveBottom.Action";
  public const string MoveDown =     "MoveDown.Action";
  public const string MovePane =     "MovePane.Action";
  public const string MoveRoot =     "MoveRoot.Action";
  public const string MoveTop =     "MoveTop.Action";
  public const string MoveUp =     "MoveUp.Action";
  public const string OnlineHelp =     "OnlineHelp.Action";
  public const string PrintModule =     "PrintModule.Action";
  public const string SyndicateModule =     "SyndicateModule.Action";

}


Or you can define your own key and put it in as a literal.

CmdName The name of the command; again, you can either define your own, or use the same built in constants listed above. In short, this is the value of the key you use in the GetString function above.
CmdArg This value is almost always blank. It is available so that you might pass in additional information to the action that will be processing the menu option.
Icon The URL to the icon to display with the Action menu option, or link.
Url If this menu will be processing the Edit link, just use EditUrl() here. If it is for some other key, use EditUrl(keyValueHere); This tells DotNetNuke what URL to create to load the specified component.
UseActionEvent Causes the portal to raise an Action Event on the server and notify any registered event listeners. Most of the time you will make this value false.
Secure What security level does the user need to be able to access this event? You can use one of the following constants from the DotNetNuke.Security namespace:

public enum SecurityAccessLevel
{
    ControlPanel = -3,
    SkinObject = -2,
    Anonymous = -1,
    View = 0,
    Edit = 1,
    Admin = 2,
    Host = 3,
}

Visible Extra control over visibility. True or false. Most of the time you will make this true.
NewWindow Will this pop up a new browser window? If so, make this value true. Otherwise, leave it false. Most of the time you will make this value false.

So in the process of explaining the action menus, we’ve introduced the concept of resource files. This is something we will take a look at in the next post of this series.

 

Other post in DotNetNuke - Module Development

Related Post

  • DotNetNuke Modules – Creating Base ModulesDotNetNuke Modules – Creating Base Modules Now that we have DotNetNuke installed into Visual Studio we can go ahead and create our first modules. Actually, creating the modules is pretty simple. But it is even easier to do it wrong, which...
  • DotNetNuke Modules – Internationalization (part 2)DotNetNuke Modules – Internationalization (part 2) Last Thursday, we looked at how you could change the text of the modules in DotNetNuke.  Today, we want to show you how to add that same capability to your own modules. When you created your...
  • DotNetNuke Modules – Retrieving SettingsDotNetNuke Modules – Retrieving Settings On Monday we discussed how to save setting information for our modules.  Today we want to pick back up where we left off and deal with retrieving that information, both in the LoadSettings() metho...
  • DotNetNuke Modules – Labels w/ no HelpDotNetNuke Modules – Labels w/ no Help While the bulk of the labels you use on a module will be DotNetNuke labels, occasionally you want to be able to put text on the screen that doesn't need context help and doesn't need to be associat...
  • DotNetNuke Modules – PortalModuleBaseDotNetNuke Modules – PortalModuleBase We've been through most of the basics now with respect to creating the View module of the DotNetNuke module set.  We will be moving on to the Settings module next.  But before we do, we need to re...