On a complex page, where there are different sections that need to be present in the template, but may not all have content added via Craft entries I need to stop the empty areas from being output (e.g. a set of div's that will create an ugly empty space in the page).
I can successfully do this for empty simple entries - like this:
{% if entry.modelTitleType %}
<div class="col-1-1">
<h2>{{ entry.modelTitleType }}</h2>
<p>{{ entry.modelIntroType }}</p>
</div>
{% endif %}
So the div enclosed by the 'if' statement is only output if there's an entry added for 'modelTitleType'. But I cannot get this to work for a Matrix entry!
How do I wrap an 'if' statement around a Matrix block like this, so it is only output if there's data added?
<ul class="selector padded-top inline-list">
{% for block in entry.modelDataType1 %}
{% if block.type == "type" %}
<li><a class="button-list selected" id="show-type1" title="{{ block.typeName }}">{{ block.typeName }}</a></li>
{% endif %}
{% endfor %}
{% for block in entry.modelDataType2 %}
{% if block.type == "type" %}
<li><a class="button-list" id="show-type2" title="{{ block.typeName }}">{{ block.typeName }}</a></li>
{% endif %}
{% endfor %}
</ul>
I've tried:
{% if entry.modelDataType1 %}
But this doesn't work...
Any help would be very much appreciated!
Many thanks.