1

I am building a plugin and in that plugin I am trying to grab all entries including disabled ones. My structure is a single entry as the parent and then it will have multiple levels of children. Currently I am grabbing the main parent with this code.

{%   set events = craft.entries.section('events').first() %} 

Then I am doing nested for loops to work my way down such as the following.

{% for event in events.children() %}
   {% for day in event.children %}
      {% for session in day.children() %}
      {% endfor %}
   {% endfor %}
{% endfor %}

This works just fine but the issue is it will not return the disabled entries. I have noticed the status(null) when you are doing a find but I have not figured out a way to do it with the for loops. I intend to keep the relationship structure in the ui so I am not looking to just get a random ordered list of all entries.

Any help would be appreciated and I am open if there is a more efficient solution.

1
{% set events = craft.entries.section('events').first() %} 
{% for event in events.children().status(null).find() %}
   {% for day in event.children().status(null).find() %}
      {% for session in day.children().status(null).find() %}
      {% endfor %}
   {% endfor %}
{% endfor %}

event.children() does not return an array of elements but an object of type ElementCriteriaModel the same as craft.entries thus you can append whatever you want until you execute it with find() or first()

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.