I am trying to display a list of entries. Specifically the parent entry and it's children's entry.
I started off using this:
{% nav page in craft.entries.section('forms').isChildOf.slug('applicant-form') %}
<li>
{{ page.getLink() }}
{% ifchildren %}
<ul>{% children %}</ul>
{% endifchildren %}
</li>
{% endnav %}
But this only displays the Parent.
I found this solution on Stack here, and all the children display but not the parent. I also wonder if this is the best solution to display the children as it seems a bit more lines than what is in the Craft docs.
Many thanks.
{% set topLevel = (entry.level == 1) ? entry : entry.getAncestors().level(1).first() %}
{% if topLevel.hasDescendants %}
<ul>
{% set nav = topLevel.getDescendants() %}
{% nav page in nav %}
{% if page.id != entry.id %}
<li>{{ page.getLink() }}</li>
{%else%}
<li>{{page}}</li>
{%endif%}
{% ifchildren %}
<ul>
{% children %}
</ul>
{% endifchildren %}
{% endnav %}
</ul>
{% endif %}