我需要重寫ContentAreaRenderer以在所有模板上實現DisplayOptions。AreaContentRenderer Ctor不需要IContentAreaItemAttributeAssembler
我需要顯示選項在ContentArea中呈現,以便它會影響所有模板。
香港專業教育學院試圖實施該解決方案 https://world.episerver.com/blogs/Anders-Hattestad/Dates/2014/8/Extending-ContentArea-to-use-custom-CSS-class-on-child-elements/
錯在 我得到的錯誤 「ContentFragmentAttributeAssembler是過時的使用IContentAreaItemAttributeAssembler代替」 當我改變的類型我得到,因爲基本構造的問題不採取EN IContentAreaItemAttributeAssembler而是過時的ContentFragmentAttributeAssembler
public class ContentAreaRendererWithDisplayOptionWithCss : ContentAreaRenderer
{
private readonly DisplayOptions _displayOptionsOwn;
private readonly IContentRepository _contentRepositoryOwn;
public ContentAreaRendererWithDisplayOptionWithCss()
: this(
ServiceLocator.Current.GetInstance<IContentRenderer>(),
ServiceLocator.Current.GetInstance<TemplateResolver>(),
ServiceLocator.Current.GetInstance<IContentAreaItemAttributeAssembler>(),
ServiceLocator.Current.GetInstance<IContentRepository>(),
ServiceLocator.Current.GetInstance<DisplayOptions>())
{
}
public ContentAreaRendererWithDisplayOptionWithCss(
IContentRenderer contentRenderer,
TemplateResolver templateResolver,
IContentAreaItemAttributeAssembler attributeAssembler,
IContentRepository contentRepository,
DisplayOptions displayOptions)
: base(contentRenderer,
templateResolver,
attributeAssembler,
contentRepository,
displayOptions)
{
_displayOptionsOwn = displayOptions;
_contentRepositoryOwn = contentRepository;
}
}