I need to overrid the ContentAreaRenderer to implement DisplayOptions on all templates.
I need the display option to render in the ContentArea so that it will affect all templates.
Ive tried to implement this solution https://world.episerver.com/blogs/Anders-Hattestad/Dates/2014/8/Extending-ContentArea-to-use-custom-CSS-class-on-child-elements/
What goes wrong I get the error "ContentFragmentAttributeAssembler is obsolete use IContentAreaItemAttributeAssembler instead" When i change the type i get a problem because of the base constructor does not take en IContentAreaItemAttributeAssembler but rather the obsolete ContentFragmentAttributeAssembler
public class ContentAreaRendererWithDisplayOptionWithCss : ContentAreaRenderer
private readonly DisplayOptions _displayOptionsOwn;
private readonly IContentRepository _contentRepositoryOwn;
_displayOptionsOwn = displayOptions;
_contentRepositoryOwn = contentRepository;
Which version of epi you are using? I see constructor with `IContentAreaItemAttributeAssembler` type.
If you need to capture `DisplayOptions` just stick with existing constructor (even it receives `ContentFragmentAttributeAssembler`) but call base constructor with `IContentAreaItemAttributeAssembler` received from `ServiceLocator`.
Just out of curiousity - what you trying to achieve with custom CA renderer? Why you need to "preserve" passed in display options?
@Valdis: Thanks for your time! I am using CMS 10.10.1.
Im trying to implement custom display options. Maybe i got this wrong but i thought i need to render the display options into the view. And since i want the custom display options in all views i thought i need to make sure they render in the Content Area wrapping the view. No?
Im guessing by your answer that im not aproaching this correctly. What is your suggestion?
"need to render display options into the view".. sorry but it's still a bit unclear on exact requirements here. I'm sure whether you approach problem from right or wrong angle, that's why I'm asking :)
I've been playing around with display options a lot. You can take a look at episerver bootstrap area renderer (don't afraid of "bootstrap" nowadays that lib has less and less in common with bootstrap). It's more like general contributions to EPiSerer Content Area. Maybe you can find solution there..
Thank you for asking, it means you are not giving up on me. :D
Ill explain what i think i understand how this works. And then maybe you can see if i am missunderstanding it.
Basically the requirement is to give the editor the option to render the content of a CA with any CSS-classes that we want wrapped around it. Ive understood that custom DisplayOptions can do this but we need to extend the DisplayOptions to include a CSS-class and also extend the ContentAreaRenderer to use this new css class.
Im following this
And when i do i get problems cause the type of some of the parameters in the constructor gets marked as obsolete, and when i change them to the new type the base class constructor wont work. Does this make sense?
Makes sense, but then I would go with ordinary custom css class support from https://github.com/valdisiljuconoks/EPiBootstrapArea this package. You can read more here: https://github.com/valdisiljuconoks/EPiBootstrapArea/blob/master/README.md#customize-generated-css-classes.