# Active link

**URL:** <https://www.ruby-forum.com/t/active-link/134262>\
**Category:** Radiant CMS\
**Created:** [April 9, 2008, 11:39am UTC](https://www.ruby-forum.com/t/active-link/134262 "2008-04-09T11:39:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![berri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@berri](https://www.ruby-forum.com/u/berri)\
**Post date:** [April 9, 2008, 11:39am UTC](https://www.ruby-forum.com/t/active-link/134262/1 "2008-04-09T11:39:35Z")

</div>

Hi, I need to use for active link another style as is mentioned below  
but it doesnt works. What is bad in my code?

- 
- 

Thank you.

---

<div class="post-metadata">

**Author:** ![berri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@berri](https://www.ruby-forum.com/u/berri)\
**Post date:** [April 9, 2008, 1:48pm UTC](https://www.ruby-forum.com/t/active-link/134262/2 "2008-04-09T13:48:52Z")

</div>

looks like navigation tag is what you need:

[http://lists.radiantcms.org/pipermail/radiant/2006-November/002547.html](http://lists.radiantcms.org/pipermail/radiant/2006-November/002547.html)

---

<div class="post-metadata">

**Author:** ![berri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@berri](https://www.ruby-forum.com/u/berri)\
**Post date:** [April 9, 2008, 2:20pm UTC](https://www.ruby-forum.com/t/active-link/134262/3 "2008-04-09T14:20:16Z")

</div>

nurullah wrote:

> looks like navigation tag is what you need:
> 
> [http://lists.radiantcms.org/pipermail/radiant/2006-November/002547.html](http://lists.radiantcms.org/pipermail/radiant/2006-November/002547.html)

But if I want to generate links automaticaly so I dont want to fill it  
into the “urls” element of “r:navigation” tag. How can I do it? Can you  
give me example or edited version of my code? Thank you.

---

<div class="post-metadata">

**Author:** ![berri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@berri](https://www.ruby-forum.com/u/berri)\
**Post date:** [April 9, 2008, 3:13pm UTC](https://www.ruby-forum.com/t/active-link/134262/4 "2008-04-09T15:13:59Z")

</div>

Vladimir,

You need something like the \<r:if\_ancestor\_or\_self\> tag that has been  
discussed previously on the list. Radius tags don’t allow other Radius  
tags inside their attributes.

Here’s the tag definition:

tag ‘if\_ancestor\_or\_self’ do |tag|  
tag.expand if tag.locals.page == tag.globals.page ||  
tag.globals.page.ancestors.include?(tag.locals.page)  
end

Then you could write something like this in your page/layout/snippet:

\<li\<r:if\_ancestor\_or\_self\>id=“current”\</r:if\_ancestor\_or\_self\>\>\<r:title /\>  
\</r:children:each\>  
\</r:find\>

Hope this helps.

Sean

---

<div class="post-metadata">

**Author:** ![berri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@berri](https://www.ruby-forum.com/u/berri)\
**Post date:** [April 9, 2008, 11:35pm UTC](https://www.ruby-forum.com/t/active-link/134262/5 "2008-04-09T23:35:26Z")

</div>

Vladimir Beran wrote:

> Where I have to put the tag definition to use the new tag?

I have a feeling we’ll be adding that to core Real Soon Now ™. I  
don’t recommend this as a general practice, but you can put the code I  
previously posted in a block at the bottom of config/environment.rb:

Page.class\_eval do

# paste the code inside here

end

Sean

---

<div class="post-metadata">

**Author:** ![berri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@berri](https://www.ruby-forum.com/u/berri)\
**Post date:** [April 9, 2008, 11:25pm UTC](https://www.ruby-forum.com/t/active-link/134262/6 "2008-04-09T23:25:58Z")

</div>

Where I have to put the tag definition to use the new tag?

---

<div class="post-metadata">

**Author:** ![berri](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/df788c/32.png) [@berri](https://www.ruby-forum.com/u/berri)\
**Post date:** [April 10, 2008, 8:31am UTC](https://www.ruby-forum.com/t/active-link/134262/7 "2008-04-10T08:31:26Z")

</div>

If I added this code to mentioned file and use the tag in Radiant  
interface, there is a text next each links telling me that undefined tag  
`if\_ancestor\_or\_self’.
