Render ContentArea without wrapping them in surrounding div
CustomContentAreaRenderer is a specialized class that overrides the default ContentAreaRenderer. It customizes the rendering behavior for content area items, specifically by rendering content items without wrapping them in a surrounding <div> element, which is typically used in the default implementation.
public class CustomContentAreaRenderer : ContentAreaRenderer
{
protected override void RenderContentAreaItem(
IHtmlHelper htmlHelper,
ContentAreaItem contentAreaItem,
string templateTag,
string htmlTag,
string cssClass)
{
if (contentAreaItem == null)
{
return;
}
var content = contentAreaItem.LoadContent();
if (content == null)
{
return;
}
// Directly render the content item without surrounding div
htmlHelper.RenderContentData(content, false);
}
}
Comments