Copied to clipboard

Flag this post as spam?

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


  • Simon Dingley 1474 posts 3431 karma points c-trib
    Aug 04, 2009 @ 13:30
    Simon Dingley
    0

    Adding a new context menu item to media section

    I am working on a new package and want to add a new context menu item to the media section only.

    I am currently adding the context menu item using BaseContentTree.BeforeNodeRender but it appears in teh content menu as well - any help would be appreciated.

    Thanks

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Aug 04, 2009 @ 14:04
    Simon Dingley
    0

    In addition I would like my context menu to appear on the root element as well which it currently doesn't, only children of the root node

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Aug 06, 2009 @ 11:02
    Simon Dingley
    0

    Ok, 1 of my 2 problems now sorted.

    To only add my context menu item to the media tree nodes I simply needed to check that:

    node.NodeType.ToLower() == "media"

    The second issue is still unresolved and I am almost at a dead end with it. I need to add my context menu item to the root media node and can find no way to achieve this so if anyone has any ideas I would appreciate some pointers.

    Thanks

  • Petr Snobelt 923 posts 1535 karma points
    Aug 06, 2009 @ 12:28
    Petr Snobelt
    100

    If you use IAction to add new item you can override CreateRootNode on your tree. There is nice tutorial in wiki

    http://our.umbraco.org/wiki/reference/backoffice-apis/tree-api-to-create-custom-treesapplications

    ( Edited as the URL was broken - Chris )

  • Simon Dingley 1474 posts 3431 karma points c-trib
    Aug 06, 2009 @ 14:53
    Simon Dingley
    0

    Thanks very much Peter, that link was a huge help. I think I will write up a blog post about this as it has been quite a headache to get to this point. Here is my final override method in the meantime in case it helps someone else.

            protected override void CreateRootNodeActions(ref List<IAction> actions)
            {
                base.CreateAllowedActions(ref actions);
                //- Clone the base actions
                List<IAction> rootNodeActions = new List<IAction>(actions);
    
                //- Clear the list so we can inject our new menu item where we want it
                actions.Clear();
    
                //- Iterate through the base actions
                foreach (IAction action in rootNodeActions)
                {
                    actions.Add(action);
                    if (action.Alias.ToLower() == "sort")
                    {
                        //- Add our new action in required location
                        actions.Add(SortAction.Instance);
                    }
                } 

    I can finally start putting the finishing touches to my package.

Please Sign in or register to post replies

Write your reply to:

Draft