I am using a table field to display credits on a portfolio page. The table field has three columns: hva, hvem and url.

The url should be optional and I want to set up an if statement showing it as a link if it has a value. Is this possible using the table field?

Also, the table field can have multiple rows.

I have tried to set up an if for row.url to see if has a value. And an else for when there is no URL.

{% if entry.credits|length %}
    {% for row in entry.credits %}
        {% if row.url == 0 %}
            <li><span class="bold">{{ row.hva }}:</span> <a href="{{ row.url }}">{{ row.hvem }}</a></li>
        {% else %}
            <li><span class="bold">{{ row.hva }}:</span> {{ row.hvem }}</li>
        {% endif %}
    {% endfor %}
{% endif %}

1 Answer 1


You were close...

Chaning this:

{% if row.url == 0 %}    

to this:

{% if row.url|length %}

should do it for you.


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.