简体   繁体   中英

Customizing Optimizely (Episerver) block outer div css class

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM