Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Chris Perks 32 posts 114 karma points
    May 01, 2014 @ 12:05
    Chris Perks
    0

    Add context menu item in Umbraco 7

    Hi,

    In previous versions of Umbraco, I could add custom context menu items to a node by doing something like:

    public class RegisterEvents : ApplicationBase
    {
    public RegisterEvents()
    {
    BaseMediaTree.BeforeNodeRender += new BaseMediaTree.BeforeNodeRenderEventHandler(MediaTree_BeforeNodeRender);
    }

    private void MediaTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
    {
    if (node.Menu != null && node.NodeType == "media")
    {
    node.Menu.Insert(4, MediaCopyAction.Instance);
    }
    }
    }

     

    These events aren't being fired in my build now that I've upgraded to Umbraco 7. Is there guidance on how I can correctly add context menu items to a node, in particular, a media node?

    My use case is that I'm developing a 'Copy' feature for Media Items to sit alongside delete, sort, move, etc.

     

    Thanks.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    May 02, 2014 @ 14:04
    Dave Woestenborghs
    1

    You are inheriting from ApplicationBase. That was the way to do it pre version 4.8

    For versions higher than 6.1.0 ApplicatinEventHandlers is the way to go.

    See the documentation : http://our.umbraco.org/documentation/Reference/Events/application-startup

  • John French 32 posts 83 karma points
    Apr 08, 2015 @ 05:15
    John French
    0

    Hello,

     

    I am having the same issue (umbraco 7.2.2)

     

     public class ApplicationEvents : ApplicationEventHandler
        {

            protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
            {

                      BaseTree.BeforeNodeRender += new BaseTree.BeforeNodeRenderEventHandler(this.BaseTree_BeforeNodeRender);

           }

      private void BaseTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs e)
            {
                if (node.Menu != null)
                {

     

                 }

     

             }

    }

     

     

    the function BaseTree_BeforeNodeRender is never called....

     

    did you find a solution?

     

     

  • John French 32 posts 83 karma points
    Apr 20, 2015 @ 03:24
    John French
    0

    I found a solution hooking to the new umbraco 7 tree events

     

    https://our.umbraco.org/documentation/Extending-Umbraco/Section-Trees/trees-v7

     

     

Please Sign in or register to post replies

Write your reply to:

Draft