Forum

Thread tagged as: Question, Problem

Change Menu Style

I have this in one of my navigation templates:

<perch:before>
<ul class="w-nav-list level_2">
</perch:before>
<li class="w-nav-item level_2 has_sublevel">
<a class="w-nav-anchor level_2" href="<perch:pages id="pagePath" />">
<span class="w-nav-title"><perch:pages id="pageNavText" /></span>
<span class="w-nav-arrow"></span>
</a>
<perch:pages id="subitems" encode="false" />
</li>
<perch:after>
</ul>
</perch:after>

Is there a way to only add the style element in it "has sub level" only if there is a sub level?

Nigel Coath

Nigel Coath 1 points

  • 7 years ago

Do you mean you want to style the top level button differently if there are sub-pages, or style the sub-page links themselves differently?

The top level, basically this style adds an arrow by the top level link only if there are sub level items. This is the "has sub level" style.

You may be able to do something like this to set the class of each button.

<perch:if exists="subitems"> class="x" <perch:else /> class="z" </perch:if>

Not 100% sure subitems is the right thing to check for though.

Ah that might work, thought that might be the way to go, will try! Thanks.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Yes, that should do it.