Multiple Edit Controls in DotNetNuke (DNN)

14. January 2008 22:26 by viperguynaz in DotNetNuke  //  Tags:   //   Comments (0)

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

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading

About the author

After 20 years flying F-16s in the USAF, I've had a ton of fun and I'm now doing something I enjoy almost as much, developing code.  I currently work as an ASP.NET/MVC developer for SpinSix Strategic Marketing Design in Scottsdale AZ.  I love developing ASP.NET MVC and eCommerce sites.

Month List

Page List