# Difficulties with a navigation menu and selectively showing children

**URL:** <https://www.ruby-forum.com/t/difficulties-with-a-navigation-menu-and-selectively-showing-children/122100>\
**Category:** Radiant CMS\
**Created:** [December 4, 2007, 4:55pm UTC](https://www.ruby-forum.com/t/difficulties-with-a-navigation-menu-and-selectively-showing-children/122100 "2007-12-04T16:55:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lou\_Brothers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@Lou\_Brothers](https://www.ruby-forum.com/u/Lou_Brothers)\
**Post date:** [December 4, 2007, 4:55pm UTC](https://www.ruby-forum.com/t/difficulties-with-a-navigation-menu-and-selectively-showing-children/122100/1 "2007-12-04T16:55:55Z")

</div>

Hi. I recently started using Radiant to host [http://www.vfct.com/](http://www.vfct.com/) .  
I’m not using many of the more sophisticated features (nearly everything  
is hard-coded in some way). I’d like to get away from having to  
hard-code my sidebar navigation (see  
[http://www.vfct.com/counterterrorism/odin-uldris/](http://www.vfct.com/counterterrorism/odin-uldris/) for a good example of  
what I’m doing.

Example:

CounterterrorismChild Page 1Child of Child Page 1Child Page 2

I want to display all of the children of the parent page, and then  
display the children of the current page only. In this example, Child  
Page 2 has children, but I am not showing them.

I’ve gotten close using  
\<r:children:each\>

  

But then I get all second level children including those under Child  
Page 2. I attempted to use

 

\<r:if\_url matches=“\<r:url /\>”\>…\</r:if\_url\> but it looks like \<r:url /\>  
isn’t executing or at least isn’t matching (it does work if I type the  
url in manually instead of using the tag).

 

An attempt to do this with r:navigation, feeding it the results of  
r:children:each failed as well, as r:children:each didn’t seem to  
execute within

 

\<r:navigation urls=“\<r:children:each\>\<r:title /\>: \<r:url  
/\>…\</r:children:each\>”…

 

Are the problems I’m experiencing (under 0.6.2) normal and expected? If  
so, is there a workaround? If this is not normal, could someone provide  
a quick example of working code?

 

Thanks.

---

<div class="post-metadata">

**Author:** ![Lou\_Brothers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@Lou\_Brothers](https://www.ruby-forum.com/u/Lou_Brothers)\
**Post date:** [December 4, 2007, 5:15pm UTC](https://www.ruby-forum.com/t/difficulties-with-a-navigation-menu-and-selectively-showing-children/122100/2 "2007-12-04T17:15:21Z")

</div>

Lou Brothers wrote:

> I want to display all of the children of the parent page, and then  
> display the children of the current page only. In this example, Child  
> Page 2 has children, but I am not showing them.

I haven’t tried it but this might work (or something like this):

\<r:parent\> ← switch the context to the parent of this page  
\<r:children:each\> ← for each child (of the page’s parent)  
\<r:if\_this\_is\_the\_current\_page\> ← sorry, I can’t remember  
how to match this  
\<r:children:each\> \<— for each child of this page  
\<r:link /\> ← or whatever you want to do  
\</r:children:each\>  
\</r:if\_this\_is\_the\_current\_page\>  
\</r:children:each\>  
\</r:parent\>

Maybe, these will help:

1. [http://lists.radiantcms.org/pipermail/radiant/2006-July/000888.html](http://lists.radiantcms.org/pipermail/radiant/2006-July/000888.html)
2. [Newb Menu Question - Radiant CMS - Ruby-Forum](http://www.ruby-forum.com/topic/125811)

Based on #1 above, you may need to match using: \<r:page:if\_url\>  
because that works at the level of the current page, not the level of  
the current context (which in a nested scheme will be the child/ parent  
page).

Hope this helps.

Cheers,  
Mohit.  
12/5/2007 | 12:14 AM.

---

<div class="post-metadata">

**Author:** ![Lou\_Brothers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@Lou\_Brothers](https://www.ruby-forum.com/u/Lou_Brothers)\
**Post date:** [December 6, 2007, 8:34am UTC](https://www.ruby-forum.com/t/difficulties-with-a-navigation-menu-and-selectively-showing-children/122100/3 "2007-12-06T08:34:54Z")

</div>

On Tue Dec 04 16:14:06 UTC 2007, Mohit S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> how to match this
> 
> Based on #1 above, you may need to match using: \<r:page:if\_url\>  
> because that works at the level of the current page, not the level of  
> the current context (which in a nested scheme will be the child/ parent  
> page).
> 
> Hope this helps.
> 
> Cheers,  
> Mohit.  
> 12/5/2007 | 12:14 AM.

I can’t seem to find a reference to an example of determining if a url  
is the url of the current page. My attempts at using \<r:if\_url  
matches…\> have not been successful.

---

<div class="post-metadata">

**Author:** ![Lou\_Brothers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@Lou\_Brothers](https://www.ruby-forum.com/u/Lou_Brothers)\
**Post date:** [December 6, 2007, 8:55am UTC](https://www.ruby-forum.com/t/difficulties-with-a-navigation-menu-and-selectively-showing-children/122100/4 "2007-12-06T08:55:23Z")

</div>

Lou,

Here’s a tag definition you can drop into your project’s extension  
that might help.

tag ‘if\_self’ do |tag|  
tag.expand if tag.locals.page == tag.globals.page  
end

Since we have better support for detecting the globally rendering page  
now, we should probably add it to the core.

Sean

---

<div class="post-metadata">

**Author:** ![Lou\_Brothers](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/dfb087/32.png) [@Lou\_Brothers](https://www.ruby-forum.com/u/Lou_Brothers)\
**Post date:** [December 6, 2007, 9:31am UTC](https://www.ruby-forum.com/t/difficulties-with-a-navigation-menu-and-selectively-showing-children/122100/5 "2007-12-06T09:31:10Z")

</div>

On Dec 5, 2007, at 9:52 AM, Sean C. wrote:

> Here’s a tag definition you can drop into your project’s extension  
> that might help.
> 
> tag ‘if\_self’ do |tag|  
> tag.expand if tag.locals.page == tag.globals.page  
> end
> 
> Since we have better support for detecting the globally rendering page  
> now, we should probably add it to the core.

+1

–  
John L.  
[http://wiseheartdesign.com](http://wiseheartdesign.com)
