我需要在新模块中使用原始Admin / Users作为部分,因此我继承了CustomModule中的Orchard.Users AdminController并调用了基本索引操作并添加了具有更高优先级的自定义路由:
//AdminController
public ActionResult IndexWithJS(UserIndexOptions options, PagerParameters pagerParameters)
{
base.Index(options,pagerParameters);
return View("Index");
}
//Route
[OrchardFeature("MyModule.Users")]
public class Routes : IRouteProvider
{
public IEnumerable<RouteDescriptor> GetRoutes()
{
yield return new RouteDescriptor()
{
Priority = 100,
Route = new Route("Admin/Users/",
new RouteValueDictionary
{
{"area", "MyModule.Users"},
{"controller", "Admin"},
{"action", "IndexWithJS"},
},
new RouteValueDictionary(),
new RouteValueDictionary { { "area", "MyModule.Users" } },
new MvcRouteHandler())
};
}
public void GetRoutes(ICollection<RouteDescriptor> routes)
{
foreach (var route in this.GetRoutes())
{
routes.Add(route);
}
}
}
//new Index.cshtml
@model Orchard.Users.ViewModels.UsersIndexViewModel
@Html.Partial("~/Modules/Orchard.Users/Views/Admin/Index.cshtml", Model)
@Script.Include("additionalscript.js");
因此,我获得与以前相同的视图,但没有任何组等选项卡。我需要那些标签;)。有没有人之前有过同样的问题,并且如何在不修改任何Orchard基础模块的情况下如何做到这一点?
编辑:我的INaigationProvider
:
public void GetNavigation(NavigationBuilder builder)
{
builder.Add(this.T("Users"), "11", menu =>
{
menu.Add(T("Users"), "1", item => item.Action("IndexWithJS", "Admin", new { area = "MyModule.Users" }).LocalNav().Permission(StandardPermissions.SiteOwner));
});
}
现在我正在获取标签,但是“用户”标签是重复的。如果我不包含我自己的NavigationProvider,则不会显示任何标签。
答案 0 :(得分:0)
通过实施INavigationProvider
界面并使用LocalNav()
方法为第3级菜单项控制选项卡。
public void GetNavigation(NavigationBuilder builder) {
builder.AddImageSet("webshop")
.Add(T("Customers"), "7", menu => menu.Action(...})
.Add(T("Details"), "0", item => item.Action(...}).LocalNav())
.Add(T("History"), "1", item => item.Action(...).LocalNav())
.Add(T("Contact"), "2", item => item.Action(...).LocalNav()));
}
参考:http://docs.orchardproject.net/Documentation/adding-admin-menu-items