我已阅读并尝试重现此问题/答案How to extend Orchard navigation module to add images to menu items
中的步骤但是得到了下一个错误:
https://dl.dropboxusercontent.com/u/86009304/MenuImagePart.png
@using Orchard.Utility.Extensions;
@using System.Dynamic
@{
/* Getting the menu content item
***************************************************************/
var menu = Model.Content.ContentItem;
/* Creating a unique CSS class name based on the menu item
***************************************************************/
// !!! for some reason the following code throws: 'string' does not contain a definition for 'HtmlClassify'
//string test = menu.ContentType.HtmlClassify();
string cssPrefix = Orchard.Utility.Extensions.StringExtensions.HtmlClassify(menu.ContentType);
var uniqueCSSClassName = cssPrefix + '-' + Model.Menu.MenuName;
/* Adds the normal and hovered styles to the html if any
***************************************************************/
if (menu.MenuImagePart != null)
{
if (!string.IsNullOrWhiteSpace(menu.MenuImagePart.Image.Url))
{
using(Script.Head()){
<style>
.@uniqueCSSClassName {
background-image: url('@Href(menu.MenuImagePart.Image.Url)');
width: @{@menu.MenuImagePart.Image.Width}px;
height: @{@menu.MenuImagePart.Image.Height}px;
display: block;
}
</style>
}
}
if (!string.IsNullOrWhiteSpace(menu.MenuImagePart.HoverImage.Url))
{
using(Script.Head()){
<style>
.@uniqueCSSClassName:hover {
background-image: url('@Href(menu.MenuImagePart.HoverImage.Url)');
width: @{@menu.MenuImagePart.HoverImage.Width}px;
height: @{@menu.MenuImagePart.HoverImage.Height}px;
}
</style>
}
}
}
}
<a class="@uniqueCSSClassName" href="@Model.Href">@Model.Text</a>
我做错了什么以及如何创建此图片以添加到新创建的“内容菜单项”?
答案 0 :(得分:0)
你有一个contentpicker字段,你想要一个mediapickerfield(如果你是Orchard 1.6)。