Display a Data Collection field IF NOT empty
With this little bit of code, you can dynamically display fields based on whether or not the...
With this little bit of code, you can dynamically display fields based on whether or not the values are empty.
For example, let's say you have a field called Color. And when there is no value for the Data Item you don't want the <p> line with 'My Color:" to display with no value. So you can check if the value of Coloris empty. If the fields value is empty DO NOT render the HTML between the IF statement. If it's value is not empty, then proceed to display the line in the layout.
{% if color != "null" -%}<br /> <p>My Color: {{color}}</p> <br />{% endif -%}
Originally sourced from the BlueberryCMS knowledge base.
Was this article helpful?
Related articles
Data Collection Usage Guide
Website Portal › Data Collections
How to create a Data Collection
Website Portal › Data Collections
How to edit a Data Collection
Website Portal › Data Collections
How to add Items to a Data Collection
Website Portal › Data Collections
How to delete a Data Collection
Website Portal › Data Collections