1

I'm aiming to display disabled entries for a logged in user and a message if no entries with this criteria exist. I've tried two different ways without success.

Version 1 gets all entries - live and disabled, gets those by the logged in user, and then tests for the entry status of disabled (which doesn't work).

{% set entries = craft.entries
    .section('profileEntry')
    .status(null)
    .all() %}

     {% for entry in entries %}

        {% if currentUser.id == entry.author.id %}

            {% if entry.status == entry.status('disabled') %}

                <p>{{ entry.title }}</p>

                {% else %}

                <p>No entries exist</p>

            {% endif %} 

        {% endif %}     


    {% endfor %}

Version 2 only gets the disabled status entries, then the entries by the logged in user. Which doesn't work either.

{% set entries = craft.entries
    .section('profileEntry')
    .status('disabled')
    .all() %}    

{% for entry in entries %}

        {% if currentUser.id == entry.author.id %}

        <p>{{ entry.title }}</p>

        {% else %}

        <p>No entries exist</p>

        {% endif %}


{% endfor %}

1 Answer 1

2

Why don't you just grab disabled entries from the author?

{% set entries = craft.entries
    .section('profileEntry')
    .status('disabled')
    .authorId(currentUser.id)
    .all() %} 

Then you can loop those

{% for entry in entries %}
    {{ entry.title }}
{% else %}
    no entries found
{% endfor %}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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