Link classes at different levels

in PdoMenu I have a 3 level menu. How do I add different classes to the links at each level? The class must be applied to the link and not its container…

Parent <li><a class="level1class" href="[[+link]]">####</a></li>
Child <li><a class="level2class" href="[[+link]]">####</a></li>
Grandchild <li><a class="level3class" href="[[+link]]">####</a></li>

In the template there is an available placeholder [[+level]] (respectively [[+wf.level]]) that probably can be used to determine the right class

<li><a class="[[+level:is=`1`:then=`level1class`]]" href="[[+link]]">####</a></li>
//or maybe even
<li><a class="level[[+level]]class" href="[[+link]]">####</a></li>
1 Like

I’ll try that thank you - I was hoping to use inline templates so the second option might be preferable.

That works beautifully thank you - both ways.

for inline tpls replace all [[....]] with {{....}}

1 Like

There’s actually a built-in css property for this, no need to use the level placeholder.

From the docs:

&levelClass
Class for each level of the menu. For example, if you specify «level», it will produce «level1», «level2» etc.

1 Like

This topic was automatically closed 2 days after discussion ended and a solution was marked. New replies are no longer allowed. You can open a new topic by clicking the link icon below the original post or solution and selecting “+ New Topic”.