Curious about navigation links

Hi there,

I’m just about to start working again on my new personal webpage and I look forward to maybe realize this with MODX. One answer I didn’t find is - how is navigation done? I mean, how to create a dynamic navbar? Level 1? Level 2?

Would be great if someone could give me a hint.

Thanks in advance, regards, Thomas

Hi Thomas

Welcome to the MODX forums.

The two most commonly used tools to generate dynamic navigation are:

pdoMenu
https://docs.modx.pro/en/components/pdotools/snippets/pdomenu

Wayfinder
https://docs.modx.com/extras/revo/wayfinder

I just created one yesterday, so here’s how I did it with Wayfinder:

First, the basic Wayfinder call, defining the startId and more important as you requested the level:

[[Wayfinder? &startId=`0` &level=`1`]]

In my case I wanted to change the default class name for the “active” site from .active to .current. I also wanted to apply the .current class on the li-tag and not as by default on the a-tag. To achieve this I created a chunk template (called rowTpl) and referenced it together with the new class name in the Wayfinder call:

[[Wayfinder? &startId=`0` &level=`1` &rowTpl=`rowTpl` &hereClass=`current`]]

The rowTpl chunk looks like this:

<li [[+wf.classes]]><a href="[[+wf.link]]" title="[[+wf.title]]">[[+wf.linktext]]</a></li>

There’s plenty more attributes and settings to be adjusted for you liking, just take a look at the Docs.

Remember you can always hide a single resource from your navigation by editing it under the “Document”-tab and checking the little box named “Hide From Menus”.

That helps a lot!

Many thanks to you!

Regards, Thomas