Wayfinder: Display the Resources that are "under" another Resource with Wayfinder

131 Views Asked by At

I am developing a website that has a main navigation on top and then some different navigations in the right sidebar (here).

I am recalling them with Wayfinder and now I would like to display them in "Tree" structure in the sidebar.

For example for the Resource AVB(39) I have 2 under resources: "RESOURCE UNDER RESOURCE AVB #1" and "RESOURCE UNDER RESOURCE AVB #2".

How can I display them in a "Tree" structure? Something Like

AVB

  • RESOURCE UNDER RESOURCE AVB #1
  • RESOURCE UNDER RESOURCE AVB #2

This is my actual code:

[[!Wayfinder? &startId=`5` &level=`0`]]
2

There are 2 best solutions below

0
On

You could do something like this.

[[Wayfinder? &startId=`[[*parent]]` ]]

Or if you are a few level deep then check out the UltimateParent snippet, which will allow you got a certain amount of levels up. https://modx.com/extras/package/ultimateparent

For example

[[Wayfinder? &startId=`[[UltimateParent? &topLevel=`2`]]` ]]
0
On

You may need to run UltimateParent uncached like this: [[!UltimateParent]]