Adding Admin Menus and Tabs

Topics: Core, Writing modules
Jan 11, 2014 at 12:21 PM
Hi,
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);
            }

            builder
                
                // Image set
                .AddImageSet("webshop")

                // "Webshop"
                .Add(item => item
 
                    .Caption(T("Webshop"))
                    .Position("2")
                    .LinkToFirstChild(true)
                
                    // "Customers"
                    .Add(subItem => subItem
                        .Caption(T("Customers"))
                        .Position("2.1")
                        .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
                        .Caption(T("Orders"))
                        .Position("2.2")
                        .Action("Index", "OrderAdmin", new { area = "Orchard.Webshop" })
                    )
                );
        }
The menu is only showing:
Webshop
Orders

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.?

Thanks
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 https://orchard.codeplex.com/workitem/19629 What you can do is to use LinkToFirstChild(false) and the top menu item (Webshop) will only show/hide Customers and Orders.