Display a Data Collection field IF NOT empty Print

  • Data Collection
  • 0

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 Color is 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" -%}
<p>My Color: {{color}}</p>
{% endif -%}

 

 


Was this answer helpful?

« Back

Powered by WHMCompleteSolution