1

I am migrating a Craft 2 site to Craft 3 and as part of that need to migrate from the Navee plugin to the Verb Navigation plugin.

The navigation data import worked fine (Thank you Verbb plugin!), but I am running into issues getting the navigation content to show the same output with the available plugin navigation rendering options and queries.

One issue I am running into is for the sidebar navigation I want to display the entire navigation tree of the current top-level ancestor and then highlight the current active node inside of that.

Navee has an option called "startWithAncestorOfActive" that makes that very easy to achieve: https://github.com/fromtheoutfit/navee/wiki/Parameters#startwithancestorofactive

I am thinking I need to leverage the "ancestorOf" parameter in my navigation query, but I am not sure how to pass in the currently active node into it to get the top-level ancestor for the current page I am viewing.

Any thoughts?

1 Answer 1

1

You can use craft.navigation.getActiveNode() to get the active node, and then to output your nodes, you can use that node as the ancestor.

{% set activeNode = craft.navigation.getActiveNode() %}
{% set nodes = craft.navigation.nodes().descendantOf(activeNode).all() %}
1
  • Thank you for pointing me to the solution!
    – gstewart
    Jan 11 at 23:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.