Copied to clipboard

Flag this post as spam?

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


  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Jul 08, 2009 @ 18:43
    Chris Houston
    1

    Is it possible to add an item to the Context Menu in Tree's other than Media & Content?

    Hi All,

    I have been trying to add an item to the context menu in the DataType's section of the Settings tree, but it seems that it is only possible to add items to the Content and Media trees?

    The following example code just adds a line to the Umbraco log with the ContentTree node Type and it seems the BeforeNodeRender is only fired when you are in the Content and Media sections?

    using System;
    using umbraco.BusinessLogic;
    using umbraco.cms.presentation.Trees;
    using umbraco.interfaces;

    namespace Vizioz.Demo
    {
      
        public class DemoActionEvents : ApplicationBase
        {
            public DemoActionEvents()
            {
            BaseTree.BeforeNodeRender += BaseContentTree_BeforeNodeRender;
            }

            static void BaseContentTree_BeforeNodeRender(ref XmlTree sender, ref XmlTreeNode node, EventArgs
            {
                Log.Add(LogTypes.Custom, 1, node.NodeType);
                // This should write the Tree Node type to the Umbraco Log... as you will see you only get content or media.
            }
        }
    }

    Is there any way around this or is this a bug?

    Cheers,

    Chris

  • Tim 225 posts 690 karma points
    Jul 08, 2009 @ 19:20
    Tim
    1

    Hi Chris,

    I've had a dig in the source code and it seems the DataTypes menu tree does not implement the BeforeNodeRender event.

    This works for the content based trees because they inherit from BaseContentTree which fires the Event in their render methods.

    Not sure if this is because it has been missed or there is some subtle reason why it hasn't been implemented. I suggest raising a Codeplex request on this and then one of the core team can take a look at it. Let me know when you've submitted the codplex issue and I'll see if I can submit a patch for this.

    Kindest Regards

    Tim

     

     

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Jul 08, 2009 @ 20:02
    Chris Houston
    0

    Hi Tim,

    Thank you for looking into this for me. I have added an item to codeplex:

    http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=23428

    If you are able to create a patch that would be great, I was really surprised that this only works on the Content and Media trees as it's an excelent feature to enable great extensions to all areas of Umbraco.

    Best regards,

    Chris

     

  • Aaron Powell 1708 posts 3046 karma points c-trib
    Jul 09, 2009 @ 05:18
    Aaron Powell
    1

    I'm not sure how well the events model is being supported, Shannon will be the best person to answer this.

    But in the mean time you can solve the problem be inheriting the class loadDataTypes and then overriding the CreateAllowedActions method and add your own custom action in there.

    You next need to change the entry in the umbracoAppTree database table (for the treeAlias datatype) to be your class + assembly.

  • Chris Houston 535 posts 980 karma points MVP admin c-trib
    Jul 09, 2009 @ 13:26
    Chris Houston
    1

    Hi Slace,

    Thanks for your reply, I've followed your little guide and have it sorted now and just added a blog post with my code in case someone else comes across this forum post wanting to do the same thing!

    http://blog.vizioz.com/2009/07/how-to-add-items-to-document-types.html

    I also added a comment to my Codeplex issue as I found the below issue which is very similar issue so mine mentioned above can be removed by some with authority to do so!

    http://umbraco.codeplex.com/WorkItem/View.aspx?WorkItemId=21623

    Thank you all for your help!

    Cheers,

    Chris

Please Sign in or register to post replies

Write your reply to:

Draft