通过 INavigationProvider 将菜单项添加到主菜单,但它不会显示? [英] Added menu item to the main menu through INavigationProvider but it won't show?

查看:50
本文介绍了通过 INavigationProvider 将菜单项添加到主菜单,但它不会显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Orchard cms 1.5.1 我创建了一个模块,其中包含从 Web 服务获取列表的控制器.当启用此模块时,我想在主菜单中添加一个菜单项.为此我创造了主菜单如下:

Using Orchard cms 1.5.1 I have created a module which contains controller that fetches list from a web service. I want to add a menu item in main menu when this module is enabled. For that i have created MainMenu as follows:

public class MainMenu:INavigationProvider
{
    public Localizer T { get; set; }
    public String MenuName
    {
        get { return "main"; }
    }
    public void GetNavigation(NavigationBuilder builder)
    {
        builder.Add(menu => menu.Add(T("Fetched List"), "4", item => item.Action("Index", "FetchedList")));
    }
}

启用我的模块后,导航不会显示该菜单项.我做错了什么吗?

When my module is enabled, navigation won't show that menu item. Am i doing something wrong?

推荐答案

从 Orchard 1.5.0 开始,INavigationProvider 不再用于在前端构建菜单(它仍然用于构建仪表板的管理菜单).您需要实现 IMenuProviderINavigationFilter.请参阅 David Hayden 博客上的这篇文章以获得一些提示.您还可以在 Orchard.Projections 中找到很好的示例, 和 Orchard.CulturePicker.

From Orchard 1.5.0 onwards, INavigationProvider isn't used to build menus on the front end (it is still used to build the admin menu for the Dashboard though). You need to implement either IMenuProvider or INavigationFilter. See this post on David Hayden's blog for some pointers. You can also find good examples in both Orchard.Projections, and Orchard.CulturePicker.

这篇关于通过 INavigationProvider 将菜单项添加到主菜单,但它不会显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆