# Wayfinder not setting lastClass

**URL:** <https://community.modx.com/t/wayfinder-not-setting-lastclass/7300>\
**Category:** Extras\
**Created:** [December 6, 2023, 6:38pm UTC](https://community.modx.com/t/wayfinder-not-setting-lastclass/7300 "2023-12-06T18:38:38Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bubishi](https://community.modx.com/letter_avatar_proxy/v4/letter/b/eada6e/32.png) [@Bubishi](https://community.modx.com/u/Bubishi)\
**Post date:** [December 6, 2023, 6:38pm UTC](https://community.modx.com/t/wayfinder-not-setting-lastclass/7300/1 "2023-12-06T18:38:38Z")

</div>

Hello,

I have a problem with a wayfinder call not setting lastClass, when a category has only one child.

The wayfinder call is:

[[Wayfinder?&debug=`0`&startId=`0`&level=`0`&hideSubMenus=`0`&textOfLinks=`pagetitle`&parentRowTpl=`drop12_parentRow_PHx`&parentRowHereTpl=`drop12_parentRowHere_PHx`&outerTpl=`drop12_outer`&innerTpl=`drop12_inner`&rowTpl=`drop12_row`&innerRowTpl=`drop12_innerRow`&outerClass=`menu2`&innerClass=`sub`&parentClass=`fly`&firstClass=`subtop`&lastClass=`subbot`&hereClass=`here`&selfClass=`self`&levelClass=`level`]]

The chunk “drop12\_innerRow” consists of:

- [[+wf.linktext]][[+wf.wrapper]]

The resulting html is:

- Coaching

The html of a menu part with more with one childs does set subbot in the last child element:

- Allgemeine Informationen
- Tiefenpsychologisch fundiert
- Analytisch

Any ideas how to fix this?

Kind regards  
Andre

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [December 6, 2023, 7:56pm UTC](https://community.modx.com/t/wayfinder-not-setting-lastclass/7300/2 "2023-12-06T19:56:01Z")

</div>

> [@Bubishi](#):
>
> wayfinder call not setting lastClass, when a category has only one child.

I think this is the normal behavior.

In the code, there is an explicit check to only set “last” if there is more than 1 subitem:

> <https://github.com/modxcms/Wayfinder/blob/aa5a5e9e0bf2e76ea24e44297ba0212549a0ea87/core/components/wayfinder/wayfinder.class.php#L234>

I also tested _pdoMenu_, and it works the same.

---

<div class="post-metadata">

**Author:** ![Bubishi](https://community.modx.com/letter_avatar_proxy/v4/letter/b/eada6e/32.png) [@Bubishi](https://community.modx.com/u/Bubishi)\
**Post date:** [December 7, 2023, 1:29pm UTC](https://community.modx.com/t/wayfinder-not-setting-lastclass/7300/3 "2023-12-07T13:29:01Z")

</div>

Hey,

thanks for your quick answer. It may be normal behaviour, but I think that’s kind of error by design. A last element should get lastClass set, regardless if there are other elements - the first element can be the last element.

Have you any recommandations for me, how to deal with this? I could try to change the code, I did some php programming years ago, but I would run in problems with every update.

Should I try to contact the developer, so he could change it, or maybe provide a config option in the snippet’s call like oneChildOnlySetLastClass=true/false?

Kind regards  
Andre

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [December 7, 2023, 3:09pm UTC](https://community.modx.com/t/wayfinder-not-setting-lastclass/7300/4 "2023-12-07T15:09:35Z")

</div>

> [@Bubishi](#):
>
> but I think that’s kind of error by design.

Well the code has been like this for years. Changing it now could create unexpected results with existing code.

> [@Bubishi](#):
>
> Have you any recommandations for me, how to deal with this?

Do you really need this class set?  
Maybe you can adapt your CSS do deal with such cases → for example by using the [:only-child](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-child) pseudo class.

> [@Bubishi](#):
>
> Should I try to contact the developer, so he could change it,

This extras hasn’t been updated in a long time. I suspect nobody will touch the code until there’s a compelling reason (like a fatal error).

---

<div class="post-metadata">

**Author:** ![Bubishi](https://community.modx.com/letter_avatar_proxy/v4/letter/b/eada6e/32.png) [@Bubishi](https://community.modx.com/u/Bubishi)\
**Post date:** [December 7, 2023, 4:07pm UTC](https://community.modx.com/t/wayfinder-not-setting-lastclass/7300/5 "2023-12-07T16:07:34Z")

</div>

> [@halftrainedharry](#):
>
> Maybe you can adapt your CSS do deal with such cases → for example by using the [:only-child](https://developer.mozilla.org/en-US/docs/Web/CSS/:only-child) pseudo class.

Hm, that looks like something, I’ll try this and come back, thanks alot!

---

<div class="post-metadata">

**Author:** ![Bubishi](https://community.modx.com/letter_avatar_proxy/v4/letter/b/eada6e/32.png) [@Bubishi](https://community.modx.com/u/Bubishi)\
**Post date:** [December 13, 2023, 11:38am UTC](https://community.modx.com/t/wayfinder-not-setting-lastclass/7300/6 "2023-12-13T11:38:41Z")

</div>

This worked, thanks alot!
