sitecore7 - Sitecore - Hide a rendering if a placeholder is empty -
i have simple sitecore mvc rendering contains heading field , placeholder:
<section> <div class="container"> <h2 class="m-header"><span>@html.sitecore().field("promoitemsheader")</span></h2> <div class="l-section grid"> @html.sitecore().placeholder("promoitems") </div> </div> </section> i rendering display outside of page-editing mode only if placeholder contains items. seems should simple can't find obvious / clean way of doing it.
try this:
sitecore.context.page.renderings .count(r => r.placeholder.indexof("promoitems", stringcomparison.ordinalignorecase) > -1) if have renderings info source, add together this:
sitecore.context.page.renderings .where(r => r.placeholder.indexof("promoitems", stringcomparison.ordinalignorecase) > -1) .count(r => !string.isnullorwhitespace(r.settings.datasource)) i add together new property view model returns if placeholder contains renderings.
sitecore sitecore7 sitecore-mvc
No comments:
Post a Comment