This project is read-only.

Adding Admin Menus and Tabs

Topics: Core, Writing modules
Jan 11, 2014 at 12:21 PM
I am following a series on module development where an AdminMenu.cs has been added to the root containing this code:
        public void GetNavigation(NavigationBuilder builder) {

            var requestContext = _requestContextAccessor.Value;
            var idValue = (string) requestContext.RouteData.Values["id"];
            var id = 0;

            if (!string.IsNullOrEmpty(idValue)) {
                int.TryParse(idValue, out id);

                // Image set

                // "Webshop"
                .Add(item => item
                    // "Customers"
                    .Add(subItem => subItem
                        .Action("Index", "CustomerAdmin", new { area = "Orchard.Webshop" })
                        .Add(T("Details"), i => i.Action("Edit", "CustomerAdmin", new { id }).LocalNav())
                        .Add(T("Addresses"), i => i.Action("ListAddresses", "CustomerAdmin", new { id }).LocalNav())
                        .Add(T("Orders"), i => i.Action("ListOrders", "CustomerAdmin", new { id }).LocalNav())

                    // "Orders"
                    .Add(subItem => subItem
                        .Action("Index", "OrderAdmin", new { area = "Orchard.Webshop" })
The menu is only showing:

Webshop points to CustomerAdmin. Also, the Tabs are not showing.

Is there a sample on how to add an Admin menu with Tabs. in Orchard 1.7.2.?

Jan 11, 2014 at 6:24 PM
Area route values are missing in LocalNav menu items, this might be the reason they are not displayed.

As for missing Customers in the left admin menu, LinkToFirstChild works different since Orchard 1.7. See What you can do is to use LinkToFirstChild(false) and the top menu item (Webshop) will only show/hide Customers and Orders.