1

Good morning and thank you in advance. I have one Verbb navigation called main. Underneath that, I have three nodes (see image). Under those nodes are regular links. I want my template to pull only the links from a specific node (Business Environment) under the main navigation, how would I go about doing that?

I know this is the code to get all nav: {% set nodes = craft.navigation.nodes('main').all() %} but how would I access just Business Environment?

Verbb Naviation Setup

1

One way would be to use the positionedBefore query. Let's say Node 2 has the ID of 1000. Then you would write it like this

{% set nodes = craft.navigation.nodes('main')
    .positionedBefore(1000)
    .all() %}

The output would be all nodes before the node with the ID of 1000. In your case just Business Environment.

With descendantOf you would get all items within your specified node for example. Just check the documentation an all available node queries.

To get the ID of the node just use the inspector in the control panel, go to your navigation and look for the data-id="XXXX" of the node element.

| improve this answer | |
  • Thanks Chris. Appreciate the help. – Jason Nov 21 '19 at 18:00
  • Hi Chris I have the same problem but don't see the data-id anywhere in the inspector not sure why – Steve Feb 20 at 15:42
  • Not to worry I found it using node.id :)) – Steve Feb 20 at 15:46

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.