6 years ago
How to check if a standard component has content?
Hi all,
Is there a way to check if a standard component has content? I'm using <@component id="solutions.widget.accepted-solutions-leaderboard-taplet"/> with a custom title added before in html, and i'd like to display the title only if the component has contant.
Thanks in advance.
You can also do this similar to Parshant's suggestion, but without overriding the component.
Freemarker allows you to assign a block of markup by using opening and closing assign directives instead of self-closing. Once you've assigned the markup to a variable, you can then use Freemarker built-ins to test the content.
For example, you could do something like:
<#assign componentOutput> <@component id="solutions.widget.accepted-solutions-leaderboard-taplet"/> </#assign> <#if componentOutput?? && componentOutput?length gt 0> <h3>Your component title</h3> ${componentOutput} </#if>
I've not tested this exact code, but it should get you close.