Hello, I want to establish a menu in my sidebar displaying kind of a tree view of my structure which is related to the current page that the user visits. So in the backend my menu looks like this:

Docs
- Item 1
- Item 2
-- Item 2a
-- Item 2b 

What I want to achieve now is, that when someone clicks on Item 2, he should see a menu with the correct links for this:

- Item 2
-- Item 2a
-- Item 2b 

When he clicks on Item 2a, he should also see this menu. I tried it with this:

{{ pages from=url }}
                <li class="py-1 ml-4"><a href="{{ url }}"><strong>{{ title }}</strong></a></li>
{{ /pages }}

But I need to change {{ pages from=url }} to {{ pages from=parent:url }} when no child / the level of the current page is = 2. How can I do that? I tried it with {if children} but {children} seems to be empty in my sidebar all the time.

Any suggestions? Thanks!

Answered by Erin Dalzell! Go to answer.