Copied to clipboard

Flag this post as spam?

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


  • Gavin Williams 48 posts 221 karma points
    Aug 16, 2022 @ 10:23
    Gavin Williams
    0

    What happened to TreeNodesRendering in v10?

    Anyone know what the equivalent of the TreeControllerBase.TreeNodesRendering event is in Umbraco 10? Is it even still available or has it been removed?

    How can I tap into the tree node rendering events?

    Thanks

  • Huw Reddick 1737 posts 6098 karma points MVP c-trib
    Aug 16, 2022 @ 10:42
    Huw Reddick
    100

    Hi,

    You need to create and register a menurendering notification

    public class MemberTreeNotificationHandler : INotificationHandler<MenuRenderingNotification>
    {
        /// <summary>
        /// Adds a translate action to the Dictionary menu
        /// </summary>
        /// <param name="notification">The notification details</param>
        public void Handle(MenuRenderingNotification notification)
        {
            if (notification.TreeAlias.Equals(Constants.Trees.Members))
            {
                var menuItem = new Umbraco.Cms.Core.Models.Trees.MenuItem("sendValidation", "SendValidation");
                menuItem.AdditionalData.Add("actionView", "/App_Plugins/MediaWizards/resendValidation.html");
                menuItem.Icon = "shuffle";
                notification.Menu.Items.Add(menuItem);
            }
        }
    }
    

    Then register using a composer

    public class MediaWizComposer : IComposer
    {
        public void Compose(IUmbracoBuilder builder)
        {
            builder.AddNotificationHandler<MenuRenderingNotification, MemberTreeNotificationHandler>();
        }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft