Copied to clipboard

Flag this post as spam?

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


  • Damiano Piva 5 posts 85 karma points
    Jan 22, 2024 @ 16:24
    Damiano Piva
    0

    MenuItem navigate to custom route to export all childnodes

    I wanted to create a MenuItem in Umbraco to export all child nodes of the current node without going through the default view. Unfortunately, by setting AdditionalData actionView to the route of my controller, the system doesn't work. Also, by setting NavigateToRoute to the route of my Umbraco controller, it redirects me to the login page. Here's the example code I used:

    public class ExportMenuRenderingNotification : INotificationHandler<MenuRenderingNotification>
    {
        public ExportMenuRenderingNotification() { }
    
        public void Handle(MenuRenderingNotification notification)
        {
            if (notification.TreeAlias.Equals(Umbraco.Cms.Core.Constants.Conventions.PermissionCategories.ContentCategory))
            {
                // Creates a menu action that will open /umbraco/currentSection/itemAlias.html
                var menuItem = new Umbraco.Cms.Core.Models.Trees.MenuItem("exportChildnodes", "Export");
    
                //menuItem.AdditionalData.Add("actionView", "~/umbraco/BackOffice/Api/Export/ExportChildNodes/"+notification.NodeId);
                menuItem.NavigateToRoute("~/umbraco/BackOffice/Api/Export/ExportChildNodes/"+notification.NodeId);
    
                // sets the icon to icon-wine-glass
                menuItem.Icon = "reply-arrow";
    
                notification.Menu.Items.Add(menuItem);
            }
        }
    }
    

    Can someone help me?

    Thanks a lot

    Damiano

Please Sign in or register to post replies

Write your reply to:

Draft