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?

gstewart
  • 13
  • 2

1 Answers1

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() %}
crawf
  • 3,552
  • 14
  • 27