# Tree active class on nodes

**URL:** <https://discourse.cakephp.org/t/tree-active-class-on-nodes/10073>\
**Category:** Uncategorized\
**Created:** [January 12, 2022, 8:00pm UTC](https://discourse.cakephp.org/t/tree-active-class-on-nodes/10073 "2022-01-12T20:00:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shadowx.jb](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@shadowx.jb](https://discourse.cakephp.org/u/shadowx.jb)\
**Post date:** [January 12, 2022, 8:00pm UTC](https://discourse.cakephp.org/t/tree-active-class-on-nodes/10073/1 "2022-01-12T20:00:46Z")

</div>

Can you please advise me how to define classes on the nodes tree if I clicked on SubItem 2?  
I need to add class active.

```auto
- Root
- Item -> class="active"
-- SubItem 1 -> class="active"
--- SubItem 2 -> class="active"
- Item

```

Can PHP cake do this easily?

Thank you

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [January 13, 2022, 12:28am UTC](https://discourse.cakephp.org/t/tree-active-class-on-nodes/10073/2 "2022-01-13T00:28:41Z")

</div>

This sounds like a JavaScript thing, not PHP?

---

<div class="post-metadata">

**Author:** ![shadowx.jb](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@shadowx.jb](https://discourse.cakephp.org/u/shadowx.jb)\
**Post date:** [January 13, 2022, 7:03am UTC](https://discourse.cakephp.org/t/tree-active-class-on-nodes/10073/3 "2022-01-13T07:03:48Z")

</div>

No in PHP - if page `/products/item/subitem-1/subitem-2`  
If I’m on the page, I’d like to have a highlighted path in the tree.

---

<div class="post-metadata">

**Author:** ![Zuluru](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/zuluru/32/1230_2.png) [@Zuluru](https://discourse.cakephp.org/u/Zuluru)\
**Post date:** [January 13, 2022, 4:34pm UTC](https://discourse.cakephp.org/t/tree-active-class-on-nodes/10073/4 "2022-01-13T16:34:41Z")

</div>

So this has nothing to do with “clicking”, then. What are you using to generate your menus? That’s the thing that will need to look at the current request and compare against the link you’re adding.
