Admin link URL

Topics: Core, Customizing Orchard
Jul 17, 2013 at 4:19 PM
When Orchard.Warmup adds a link to the admin menu, it does so using the following code:
        public void GetNavigation(NavigationBuilder builder) {
            builder
                .Add(T("Settings"), menu => menu
                    .Add(T("Performance"), "10.0", subMenu => subMenu.Action("Index", "Admin", new { area = "Orchard.Warmup" }).Permission(StandardPermissions.SiteOwner)
                        .Add(T("Warmup"), "10.0", item => item.Action("Index", "Admin", new { area = "Orchard.Warmup" }).Permission(StandardPermissions.SiteOwner).LocalNav())
                    ));
        }
The link that ends up added under Settings sends to /Admin/Warmup.

I followed this approach with a new module:
        public void GetNavigation(NavigationBuilder builder)
        {
            builder
                .Add(T("Settings"), menu => menu
                    .Add(T("Logging"), "5.0", subMenu => subMenu.Action("Index", "Admin", new { area = "MyModule.NewLogging" }).Permission(StandardPermissions.SiteOwner))
                );
        }
The link for the above that ends up getting added is /Admin/MyModule.NewLogging.

What determines the format of the link? I like the concept of having the link be something like /Admin/Logging, if I can.
Jul 17, 2013 at 5:37 PM
Edited Jul 17, 2013 at 5:37 PM
Another interesting twist: My controller doesn't seem to be getting hit, but my view is.

View is in Views\Admin\Index.cshtml. Controller is named AdminController and is defined as such:
    public class AdminController : Controller, IUpdateModel
    {

        #region " Private Properties "

        private IOrchardServices Services { get; set; }
        private Localizer T { get; set; }

        #endregion

        #region " Constructor "

        public AdminController(IOrchardServices services)
        {
            Services = services;
        }

        #endregion

        #region " Index "

        public ActionResult Index()
        {
            // Verify permissions.
            if (!Services.Authorizer.Authorize(StandardPermissions.SiteOwner, T("Not authorized to manage settings")))
            {
                return new HttpUnauthorizedResult();
            }

            // Get model.
            var part = Services.WorkContext.CurrentSite.As<LoggingSettingsPart>();

            // Create viewmodel.
            var model = new LoggingSettingsPartViewModel()
            {
                ServiceUrl = part.ServiceUrl
            };

            // Return viewmodel.
            return View(model);
        }

        #endregion

        #region " AddModelError "

        private void AddModelError(string key, LocalizedString errorMessage)
        {
            ModelState.AddModelError(key, errorMessage.ToString());
        }

        #endregion

        #region " IUpdateModel Members "

        bool IUpdateModel.TryUpdateModel<TModel>(TModel model, string prefix, string[] includeProperties, string[] excludeProperties)
        {
            return TryUpdateModel(model, prefix, includeProperties, excludeProperties);
        }

        void IUpdateModel.AddModelError(string key, LocalizedString errorMessage)
        {
            AddModelError(key, errorMessage);
        }

        #endregion

    }
Jul 17, 2013 at 6:04 PM
Edited Jul 17, 2013 at 6:05 PM
I added a route, and that seems to solve both problems. However, I still don't understand how the Warmup module does it without (or where it sets up the route if it uses one).
new RouteDescriptor {
    Route = new Route (
        "Admin/Logging",
        new RouteValueDictionary {
            {"area", "MyModule.NewLogging"},
            {"controller", "Admin"},
            {"action", "Index"} },
        null,
        new RouteValueDictionary {
            {"area", "MyModule.NewLogging"} },
        new MvcRouteHandler())
}
But, it's working, so I'm happy.