# Selecting current page in menu

**URL:** <https://www.ruby-forum.com/t/selecting-current-page-in-menu/147267>\
**Category:** Radiant CMS\
**Created:** [August 30, 2008, 12:58am UTC](https://www.ruby-forum.com/t/selecting-current-page-in-menu/147267 "2008-08-30T00:58:53Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bartee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bartee](https://www.ruby-forum.com/u/bartee)\
**Post date:** [August 30, 2008, 12:58am UTC](https://www.ruby-forum.com/t/selecting-current-page-in-menu/147267/1 "2008-08-30T00:58:53Z")

</div>

I have this as my menu.

I need to identify which is the current page so I can set the  
class=“here”

How can I do that ?

- Home
- [Shop](https://www.ruby-forum.com/shop/ "Shop")
- [Projects](https://www.ruby-forum.com/projects/ "Projects")
- [Gallery](https://www.ruby-forum.com/gallery/ "Gallery")
- [About Me](https://www.ruby-forum.com/aboutme/ "About Me")
- [Contact Us](https://www.ruby-forum.com/contactus/ "Contact Us")

---

<div class="post-metadata">

**Author:** ![bartee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bartee](https://www.ruby-forum.com/u/bartee)\
**Post date:** [August 30, 2008, 2:49am UTC](https://www.ruby-forum.com/t/selecting-current-page-in-menu/147267/2 "2008-08-30T02:49:26Z")

</div>

The typical way is to use \<r:navigation\>. This snippet should do what  
you like:

- 
- 

Unfortunately, it won’t let you add the “last” class, but you could add  
that with JavaScript pretty easily. If you’re using Prototype:

document.observe(“dom:loaded”, function(){  
$$(‘li:last-child’).invoke(‘addClassName’, ‘last’); });

Your other option is to use a bunch of \<r:if\_url\> tags, one on each  
link, to see whether you should add the “here” class.

Cheers,

Sean

---

<div class="post-metadata">

**Author:** ![bartee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bartee](https://www.ruby-forum.com/u/bartee)\
**Post date:** [August 30, 2008, 4:29pm UTC](https://www.ruby-forum.com/t/selecting-current-page-in-menu/147267/3 "2008-08-30T16:29:19Z")

</div>

Sean,

Thanks…

I just pasted your code into my header and poof… it worked.

I am starting to get it !!!

I am a 40 year programmer, but realize the power of things like Radiant  
CMS.

I have a lot to learn, but I am SOLD on Radiant…

Good community …

I will let y’all know when I get my 1st site up. It’s my woodworking  
hobby site, but it will teach me a whole lot and then maybe I can sell a  
site !!!

---

<div class="post-metadata">

**Author:** ![bartee](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d78d45/32.png) [@bartee](https://www.ruby-forum.com/u/bartee)\
**Post date:** [August 30, 2008, 4:48pm UTC](https://www.ruby-forum.com/t/selecting-current-page-in-menu/147267/4 "2008-08-30T16:48:13Z")

</div>

That’s great!

Cheers,  
Sean
