I'm doing, what I think should work fine, however, I'm still getting a blank table output on the page if the table field is left unfilled when creating the entry. It's like the "if" check is being ignored for some reason. The table with data outputs as expected fine. What am I missing here? Gotta be something simple. Here's a link to the page in question: http://nightowlmusic.org/family/rotiron

{% if entry.discography | length %}
        <table class="discography">
                <th colspan="3">Discography</th>
            {% for row in entry.discography %}
                <td class="release">{{ row.releaseName }}</td>
                <td class="year">{{ row.releaseYear }}</td>
                <td class="purchaseLink">
                    {% if row.purchaseLink %}<a href="{{ row.purchaseLink }}" title="Purchase the Release">Click here to purchase</a>{% endif %}
            {% endfor %}
{% endif %}
  • "...if the table field is left unfilled when creating the entry". Do you mean that you have no rows in your table? Or do you have one row, but none of the columns haven't been filled? By default, when creating a new table field in Craft, there is one row in the table. Can be a bit confusing. :) Jul 21 '15 at 20:44
  • The columns have not been filled in.
    – Herb Himes
    Jul 21 '15 at 20:45

When you define a table field, it comes with one row by default. I'm not sure why this is. You can remove this row by clicking on the - icon: screen shot

To filter out those rows in twig, try:

{% for row in entry.discography if row.releaseName %}
  • Everyone gets one table row for free. The rest will cost you.
    – Brad Bell
    Jul 21 '15 at 20:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.