I have read and try to reproduce steps from this question/answer How to extend Orchard navigation module to add images to menu items
- Have created MenuImagePart with "Image" Content Picker field
- Have added this part to "Content Menu Item"
- Changed code in MenuItemLink-ContentMenuItem.cshtml
But got next error:
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>
What I done wrong and how should I create this image to add to newly created "Content Menu Item"?