Topic: [solved] wayfinder how to include class="first" as well as "active" and "last"  (Read 590 times)

Pages: [1]   Go Down

#1: 16-Oct-2009, 02:34 AM

n!ck
Posts: 134

WWW
Howdy,

How do I get wayfinder to include class="first" as well as "active" and "last"?

I am using:
MODx version - 1.0.0
Version codename - rev 5601
Wayfinder - 2.0

Code:
[[Wayfinder? &startId=`0` &level=`0` &outerTpl=`menu wrapper` &rowTpl=`menu row` &titleOfLinks=`menutitle` &excludeDocs=`1,8,9,10,11`]]

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

I'd like it to look like this, rather than having to do [+wf.docid+] (code bloat for a simple list) to hide a background image on the first element - and what if the menu order changes, and the existing first element is moved??

Code:
<ul>
 <li class="first"><a href="#" title="blah">Blah</a></li>
 <li><a href="#" title="blah">Blah</a></li>
 <li class="active"><a href="#" title="blah">Blah</a></li>
 <li><a href="#" title="blah">Blah</a></li>
 <li><a href="#" title="blah">Blah</a></li>
 <li class="last"><a href="#" title="blah">Blah</a></li>
</ul>

Thanks in advance.
« Last Edit: 16-Oct-2009, 05:51 PM by nickf08 »

#2: 16-Oct-2009, 09:28 AM

Coding Team

sottwell
Posts: 10,502

WWW
&firstClass=`first`
sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html

#3: 16-Oct-2009, 05:51 PM

n!ck
Posts: 134

WWW
sweet - thanks Sottwell.
That does the trick!

#4: 26-Jan-2010, 09:24 AM

DaveChild
Posts: 17

Apologies for the bump - this topic appears high in Google results for searches for the issue I've had which I've now resolved, so I thought I'd post the fix here.

The problem I had was that the "last" class wasn't being applied to the first element in a wayfinder submenu. The "first" class was being applied, but I wanted both. I fixed this by changing line 93 of assets/snippets/wayfinder/wayfinder.inc.php from this:

Code:
if ($counter == ($numSubItems) && $numSubItems > 1) {

To this:

Code:
if ($counter == ($numSubItems) && $numSubItems >= 1) {

The "last" class isn't applied to the last element if there's only one element in the list.

#5: 26-Jan-2010, 03:22 PM

n!ck
Posts: 134

WWW
awesome - thanks for the heads up DaveChild
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.