Orchard CMS 菜单项上的图像

Image on Orchard CMS Menu items

如何将图像添加到我在 orchard 中的导航项?在我的果园应用程序中,我添加了 6 个导航项。如何为那里的所有项目添加图像?

前段时间有个类似的问题: Orchard CMS: Modifying a menu item alternate and iterating over the items

例如,您可以为 MenuItemLink 编写一个替代项并在其中添加您的图像。

来自其他回答:

MenuItemLink.cshtml

<a href="@Model.Href" class="my-super-cool-custom-link">
    <img src="wherever/img.jpg" />@Model.Text
</a>

作为@Xceno 回答的后续,这是我在需要此功能时所做的:

  1. 在内容定义中的 MenuPart 添加一个文本字段,名为 'Icon'

  2. 覆盖'MenuItemLink.cshtml',内容如下(我对图标使用了很棒的字体,无论你使用什么,都改变'fa'的东西):


@{
    var icon = Model.Content.ContentItem.MenuPart.Icon.Value;
}

<a href="@Model.Href">
    @if (!string.IsNullOrEmpty(icon)) {
        <i class="fa fa-@icon"></i> 
    }
    <span class="nav-label">@Model.Text</span>
</a>