Developer Ramblings
Tips and Traps in Web Development

Multiple Edit Controls in DotNetNuke (DNN)

January 14, 2008 22:26 by viperguynaz

I've developed several custom DNN modules, but none required more than the single view, edit and settings controls that are created with the starter kit.  Well for my current project, I needed two edit controls.  Creating the controls is easy if you follow any of the instructions you can find by googling "create custom dnn module".   

 What I wanted though was similar to the Events Project module that had multiple edit controls on the dropdown and on the links (bottom left corner of most module containers).  Copying the Starter Kit example proved easy to add a second edit control, but it only showed on the Module Menu DropDown, not in the list of action links at the bottom of the module.

Here's the code I started with:

public DotNetNuke.Entities.Modules.Actions.ModuleActionCollection ModuleActions
        {
            get
            {
                //create a new action to add an item, this will be added to the controls
                //dropdown menu
                ModuleActionCollection actions = new ModuleActionCollection();
                actions.Add(GetNextActionID(), Localization.GetString(ModuleActionType.AddContent, LocalResourceFile),
                    ModuleActionType.AddContent, "", "", EditUrl("Edit"), false, DotNetNuke.Security.SecurityAccessLevel.Edit,
                     true, false);
                actions.Add(GetNextActionID(), Localization.GetString(ModuleActionType.EditContent, LocalResourceFile),
                    ModuleActionType.EditContent, "", "", EditUrl("EditSlides"), false, DotNetNuke.Security.SecurityAccessLevel.Edit,
                     true, false);
                return actions;
            }
        }

This code did not add the second action item "EditSlides" to the Action link list at the bottom of the page.  After lotsss of trial and error and looking at other modules (plus reviewing the docs at http://www.dotnetnuke.com/), I finally reached the answer, putting the correct ModuleActionType - AddContent in the third parameter of AddAction.  When I switched the code to:

        public DotNetNuke.Entities.Modules.Actions.ModuleActionCollection ModuleActions
        {
            get
            {
                //create a new action to add an item, this will be added to the controls
                //dropdown menu
                ModuleActionCollection actions = new ModuleActionCollection();
                actions.Add(GetNextActionID(), Localization.GetString("EditAlbums", LocalResourceFile),
                    ModuleActionType.AddContent, "", "", EditUrl("Edit"), false, DotNetNuke.Security.SecurityAccessLevel.Edit,
                     true, false);
                actions.Add(GetNextActionID(), Localization.GetString("EditSlides", LocalResourceFile),
                    ModuleActionType.AddContent, "", "", EditUrl("EditSlides"), false, DotNetNuke.Security.SecurityAccessLevel.Edit,
                     true, false);
                return actions;
            }
        }

Then I got both the action items on the link list at the bottom of the module.  Also note that the first parameter of Localization.GetString was change to a string that coorelates to a StringName.Text entry in the resource file.  For example, EditSlides.Text = "Edit Slides" in the resource file.

And the results...two edit controls in the link list at the bottom of the module control.

 

Cheers...Don


Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Post correlati

Add comment


(Will show your Gravatar icon)  

  Country flag





Live preview

May 17. 2008 11:23