how can I conditionally output rows of an matrix, if there are any? Eg:
{if matrixfield}
<h2>Also check</h2>
{matrixfield}
<a href="{url_title}">{title}</a><br />
{/matrixfield}
{/if}
Thanks!
ExpressionEngine® Answers is a question and answer site for administrators, end users, developers and designers for ExpressionEngine® CMS. It only takes a minute to sign up.
Sign up to join this communityYep, just check to see if the matrix field total_rows
are greater than 0
{if my_matrix_field:total_rows > 0}
Matrix field has rows
{/if}
I dont have enough rep to make a comment.
So, I am not sure what you are looking for. The code below is an example how to work with conditionals for Matrix.
{matrixfield}
{if no_results}
No rows available
{/if}
{if '{row_count}' == '1'}
<a href="{url_title}">{title} - First row</a>
{/if}
<a href="{url_title}">{title}</a>
{if '{row_count}' == '{total_rows}'}
<a href="{url_title}">{title} - Last row</a>
{/if}
{/matrixfield}