Copied to clipboard

Flag this post as spam?

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


  • Taylor Mitchell 19 posts 41 karma points
    Nov 17, 2015 @ 21:09
    Taylor Mitchell
    1

    Custom Menu Item override route not using the umbraco/view/route

    This is very frustrating. So I'm trying to build a menu item, but I don't want that dumb slide out window. I need it to redirect to a new page. Which you can do using NavigateToRoute, however that stupid method adds "umbraco/views/" then cuts off the first part of my string I put in there as well.

    For Example

           var build = new MenuItem("Build", "Build");
           build.NavigateToRoute("/MySection/MySectionTree/Build");
           menu.Items.Add(build);
    

    The above will navigate to "/umbraco/views/MySectionTree/Build"

    That doesn't even make sense to me why it cuts off the first part. I need it to go to "umbraco/MySection/MySectionTree/Build"

    How does this method even work and has anyone got it to work properly.

    It gets the proper url if i comment out the navigateToRoute, but it goes in a slideout window. Any way to override that?

    Thanks

  • Stuart 7 posts 77 karma points
    Nov 18, 2015 @ 15:09
    Stuart
    0

    I'm in exactly the same boat. Just a reply so i can follow the topic (and update if and when i find an answer...)

  • Ayo Adesina 370 posts 925 karma points
    Sep 06, 2017 @ 09:20
    Ayo Adesina
    0

    at least I am not the only one.

  • Zihadul Azam 26 posts 170 karma points c-trib
    Oct 19, 2017 @ 08:35
    Zihadul Azam
    0

    The solution is: NavigateToRoute(string route) function. This onClick will open the route on a new window.

    Remember the route is composed by: /{PluginName}/{TreeAlias}/{MenuItemAlias}/{id}

    protected override MenuItemCollection GetMenuForNode(string id, FormDataCollection queryStrings)
    {
        var menu = new MenuItemCollection();
    
        MenuItem createCategory = new MenuItem("createcategory", "Create Category");
    
        createCategory.AdditionalData.Add("ParentCategoryId", id);
    
        createCategory.NavigateToRoute("/Category/categoryTree/createcategory/" + id);
    
        createCategory.Icon = "add";
    
        menu.Items.Add(createCategory);
    
        return menu;
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft