When I view a entry that's belong to a small group of children with a parent assigned. When I view the child, I want to display list all children that the child assigned to?

Is there anyway to achieve this method?


I think you're looking for the getSiblings() method. This will return all sibling entries for the current entry. You can also use getParent() to get the parent entry and getChildren() to get the entries child entries.

An example implementation is below:

{% set siblings = entry.getSiblings() %}
{% set parent = entry.getParent() %}
{% set children = entry.getChildren() %}

{% if parent|length %}
  <p>{{ parent.title }}</p>
{% endif %}

{% if siblings|length %}
  {% for entry in siblings %}
    <p>{{ entry.title }}</p>
  {% endfor %}
{% endif %}

{% if children|length %}
  {% for entry in children %}
    <p>{{ entry.title }}</p>
  {% endfor %}
{% endif %}

More info on these methods can be found in the EntryModel documentation.


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.