Admin menu items not showing up correctly

Topics: Troubleshooting
Oct 17, 2014 at 3:36 AM
Edited Oct 17, 2014 at 1:14 PM
I've added an AdminMenu.cs to the root directory in my module but I am having difficultues getting the menus to show correctly and I cannot find anything that correctly explains how to add a third level.

I am using a clean install of Orchard 1.8.1.

Below is the code I currently have. I expect to have a top level admin menu called "Entertainment News" and three second level admin menu items called Music, Film, and Books, that would link to "/admin/MusicAdmin/", etc.
using Orchard.Localization;
using Orchard.UI.Navigation;

namespace EntertainmentNews
{
    public class AdminMenu : INavigationProvider
    {
        public string MenuName
        {
            get { return "admin"; }
        }

        public AdminMenu()
        {
            T = NullLocalizer.Instance;
        }

        private Localizer T { get; set; }

        public void GetNavigation(NavigationBuilder builder)
        {
            builder

                // Image set
                .AddImageSet("Entertainment")

                // "EntertainmentNews"
                .Add(item => item

                    .Caption(T("Entertainment News"))
                    .Position("1")
                    .LinkToFirstChild(false)

                    // "Music"
                    .Add(subItem => subItem
                        .Caption(T("Music"))
                        .Position("2.1")
                        .Action("Index", "MusicAdmin")
                    )

                    // "Film"
                    .Add(subItem => subItem
                        .Caption(T("Film"))
                        .Position("2.2")
                        .Action("Index", "FilmAdmin")
                    )

                    // "Books"
                    .Add(subItem => subItem
                        .Caption(T("Books"))
                        .Position("2.3")
                        .Action("Index", "BooksAdmin")
                    )
                );
        }
    }
}
I get the Entertainment News" top level menu item and the three second level menus of "Music", "Film", and "Books", however all of the links have "/Dashboard/" inserted, such as "/Dashboard/Music/".

I've looked through the other modules but I cannot figure out how to get rid of the "/Dashboard" portion.

The second question I have is that in different tutorials and forums I also see the following:
                    // "Music"
                    .Add(subItem => subItem
                        .Caption(T("Music"))
                        .Position("2.1")
                        .Action("Index", "MusicAdmin", new { area = "EntertainmentNews" })
                    )
It's not clear to me what the "new { area = EntertainmentNews }" portion does and when I add it the menu item shows but the link drops.

The element shows
<a class="subnavicon-music">Music</a>
Finally, I'm not sure how to add a third level that will open up the tabs. I've read about LocalNav() and about just adding another level, but I've not had any success with either approach.

Any thoughts would be appreciated.
Oct 17, 2014 at 1:12 PM
Edited Oct 17, 2014 at 1:13 PM
OK, figured out the new { area = "EntertainmentNews" } portion and added a routes.cs file.

For reference for those having the same issue and not making the connection between the AdminMenu.cs and the Routes.cs, here are my updated files:

AdminMenu.cs
using Orchard.Localization;
using Orchard.UI.Navigation;

namespace EntertainmentNews
{
    public class AdminMenu : INavigationProvider
    {
        public string MenuName
        {
            get { return "admin"; }
        }

        public AdminMenu()
        {
            T = NullLocalizer.Instance;
        }

        private Localizer T { get; set; }

        public void GetNavigation(NavigationBuilder builder)
        {
            builder

                // Image set
                .AddImageSet("Entertainment")

                // "EntertainmentNews"
                .Add(item => item

                    .Caption(T("Entertainment News"))
                    .Position("1")
                    .LinkToFirstChild(false)

                    // "Music"
                    .Add(subItem => subItem
                        .Caption(T("Music"))
                        .Position("0")
                        .Action("Index", "MusicAdmin", new { area = "EntertainmentNews" })
                    )

                    // "Film"
                    .Add(subItem => subItem
                        .Caption(T("Film"))
                        .Position("1")
                        .Action("Index", "FilmAdmin", new { area = "EntertainmentNews" })
                    )

                    // "Books"
                    .Add(subItem => subItem
                        .Caption(T("Books"))
                        .Position("2")
                        .Action("Index", "BooksAdmin", new { area = "EntertainmentNews" })
                    )
                );
        }
    }
}
Routes.cs
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using Orchard.Mvc.Routes;

namespace EntertainmentNews
{
    public class Routes : IRouteProvider
    {
        public void GetRoutes(ICollection<RouteDescriptor> routes)
        {
            foreach (var routeDescriptor in GetRoutes())
                routes.Add(routeDescriptor);
        }

        public IEnumerable<RouteDescriptor> GetRoutes()
        {
            return new[] {
                new RouteDescriptor {
                    Priority = 5,
                    Route = new Route(
                        "Admin/MusicAdmin",
                        new RouteValueDictionary {
                            {"area", "EntertainmentNews"},
                            {"controller", "MusicAdmin"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "EntertainmentNews"}
                        },
                        new MvcRouteHandler())
                },
                new RouteDescriptor {
                    Priority = 5,
                    Route = new Route(
                        "Admin/FilmAdmin",
                        new RouteValueDictionary {
                            {"area", "EntertainmentNews"},
                            {"controller", "FilmAdmin"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "EntertainmentNews"}
                        },
                        new MvcRouteHandler())
                },
                new RouteDescriptor {
                    Priority = 5,
                    Route = new Route(
                        "Admin/BooksAdmin",
                        new RouteValueDictionary {
                            {"area", "EntertainmentNews"},
                            {"controller", "BooksAdmin"},
                            {"action", "Index"}
                        },
                        new RouteValueDictionary(),
                        new RouteValueDictionary {
                            {"area", "EntertainmentNews"}
                        },
                        new MvcRouteHandler())
                }
            };
        }
    }
}
I'm still not sure how to implement the tabs for the third level of the admin menu, but I'm content at the moment!

I'll post again when I figure that part out.
Marked as answer by LorenMaxwell on 10/17/2014 at 5:14 AM