Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Tag helper issue in CMS12

Vote:
 

Hi Team,

I have below tag helper code used to avoid extra divs for blocks in CMS11. but after upgrade to new CMS12 solution below code not working. Can you please let us know what is missing here to work in CMS12 framework?

<div class="row">
       @Html.PropertyFor(m => m.MainBody, new { Tag = "_CustomContentArea" })
 </div>

_CustomContentArea.cshtml this view exists under Views/Shared/DisplayTemplates

@using EPiServer.Core
@using EPiServer.Web.Mvc.Html
@model ContentArea

@{
    if (Model != null && Model.FilteredItems != null)
    {
        foreach (var item in Model.FilteredItems)
        {
            Html.RenderContentData(item.GetContent(), true);
        }
    }
}

#293395
Dec 19, 2022 16:52
Vote:
 

Can you simply use @Html.Partial("Views/Shared/DisplayTemplates/_CustomContentArea.cshtml", Model.MainBody) instead?

#293441
Dec 20, 2022 9:38
Vote:
 

If you want to skip extra element, soon renewed package will be released :)

https://github.com/valdisiljuconoks/optimizely-advanced-contentarea#skip-item-wrapper-element

But did you check what template renderers you have registered on MainBody type? Using just Tag - might not work properly. You can check templates nicely if you install EPiServer.DeveloperTools package (there is separate section for those).

#294987
Jan 19, 2023 17:34
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.