Customizing Optimizely (Episerver) block outer div css class

421 Views Asked by At

Is it possible to add css classes to auto-generated outer div for block element ? I have a simple Block with a ViewModel and a Controller and I need modify this autogenerated outer div, or optionally remove it?

I looked at other answers to this question where it was recommended ie.

@Html.PropertyFor(model => model.CurrentBlock.ClientLogos, new
{
    CustomTag = "ul",
    CssClass = "list",
    ChildrenCustomTagName = "li",
    ChildrenCssClass = "list_item"
})

Problem is when I use this syntax, model has no CurrentBlock property ???

My model is bound to ViewModel, I'm not sure if it affects this. I am very new to Optimizely.

1

There are 1 best solutions below

0
On

You can use custom tag and css class. In your example CurrentBlock is probably part of the viewModel, you can directly use model.ClientLogs. Alternativly if you want more control you can use editing attributes.

<h1 @Html.EditAttributes(x => x.Heading)>
  /* Render the Heading property, unless it it empty, then use PageName as fallback */
  @Model.Heading ?? @Model.PageName
</h1>

You can find more information about editing attributes here: https://docs.developers.optimizely.com/content-cloud/v11.0.0-content-cloud/docs/adding-editing-attributes-using-property-web-control