0
我有一個非常簡單的組件,它只包含一個圖像。Sitecore 8 MVC將類添加到呈現爲HtmlString的圖像
控制器:
public ActionResult Index()
{
ActionResult ret = null;
if (RenderingContext.Current.Rendering.Item != null)
{
IntroImageModel model =
CreateModel(RenderingContext.Current.Rendering.Item);
ret = View(model);
}
return ret;
}
private IntroImageModel CreateModel(Item item)
{
IntroImageModel introImage = new IntroImageModel();
introImage.IntroImage = new HtmlString(FieldRenderer.Render(item,
FieldNames.INTROIMAGE_INTROIMAGE));
return introImage;
}
的型號:
public class IntroImageModel
{
public IntroImageModel()
{
}
public HtmlString IntroImage { get; set; }
}
的觀點:
@model ON.LSX.FEATURE.CONTENT.Models.IntroImageModel
@{
Layout = null;
}
@Model.IntroImage
我需要一個特定的類添加到由該代碼生成的標籤,但我完全不知道該怎麼做,任何人都可以提供幫助?