# If\_url and menu sub menus

**URL:** <https://www.ruby-forum.com/t/if-url-and-menu-sub-menus/98439>\
**Category:** Radiant CMS\
**Created:** [July 14, 2006, 7:46pm UTC](https://www.ruby-forum.com/t/if-url-and-menu-sub-menus/98439 "2006-07-14T19:46:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Erik\_BSOrdway](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Erik\_BSOrdway](https://www.ruby-forum.com/u/Erik_BSOrdway)\
**Post date:** [July 14, 2006, 7:46pm UTC](https://www.ruby-forum.com/t/if-url-and-menu-sub-menus/98439/1 "2006-07-14T19:46:52Z")

</div>

I have a site structure like this. --\> denote children

Main Page  
–\>scicomp  
----\>student\_projects  
----\>instruments  
------\>gcms  
------\>ftir  
------\>sem  
–\>other areas

h3. Scientific Computing  
\<r:find url="/scicomp/"\>  
\<r:children:each order=“asc”\>

- \<r:link /\>  
\<r:if\_url matches="/instrumentation/"\>  
\<r:children:each order=“asc”\>  
\*\* \<r:link /\>  
\</r:children:each\>  
\</r:if\_url\>  
\</r:children:each\>  
\</r:find\>

I want to have a sidebar menu that when the instruments section in  
being viewed the children of the instruments page are listed. When  
that section is not being viewed are hidden. I had though that the  
above would do this but instead it always should the sub-menu. Any  
thoughts.

FYI I love that radiant does all the right stuff to be DB agnostic.

---

<div class="post-metadata">

**Author:** ![Erik\_BSOrdway](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Erik\_BSOrdway](https://www.ruby-forum.com/u/Erik_BSOrdway)\
**Post date:** [July 14, 2006, 8:11pm UTC](https://www.ruby-forum.com/t/if-url-and-menu-sub-menus/98439/2 "2006-07-14T20:11:49Z")

</div>

Erik B. Ordway wrote:

> \</r:find\>
> 
> I want to have a sidebar menu that when the instruments section in  
> being viewed the children of the instruments page are listed. When  
> that section is not being viewed are hidden. I had though that the  
> above would do this but instead it always should the sub-menu. Any  
> thoughts.

That’s because the \<r:if\_url /\> tag is being evaluated within the  
context of the child URL. You need to bump it back out so that it  
references the current page’s url. Try this instead:

\<r:page:if\_url matches=“/instrumentation/”\>  
…  
\<r:page:if\_url\>

The \<r:page /\> tag changes the context back to the current page.

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

---

<div class="post-metadata">

**Author:** ![Erik\_BSOrdway](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Erik\_BSOrdway](https://www.ruby-forum.com/u/Erik_BSOrdway)\
**Post date:** [July 14, 2006, 9:20pm UTC](https://www.ruby-forum.com/t/if-url-and-menu-sub-menus/98439/3 "2006-07-14T21:20:01Z")

</div>

Thanks. I keep forget the objecty nature of the tag syntax. It takes  
a little getting used to but it is nice.

---

<div class="post-metadata">

**Author:** ![Erik\_BSOrdway](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/e274bd/32.png) [@Erik\_BSOrdway](https://www.ruby-forum.com/u/Erik_BSOrdway)\
**Post date:** [July 14, 2006, 9:40pm UTC](https://www.ruby-forum.com/t/if-url-and-menu-sub-menus/98439/4 "2006-07-14T21:40:20Z")

</div>

Erik B. Ordway wrote:

> Thanks. I keep forget the objecty nature of the tag syntax. It takes  
> a little getting used to but it is nice.

Most of the time I think it’s what you would expect, but occasionally it  
catches you by surprise. 🙂

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