# Children + Siblings

**URL:** <https://www.ruby-forum.com/t/children-siblings/157536>\
**Category:** Radiant CMS\
**Created:** [January 12, 2009, 9:44pm UTC](https://www.ruby-forum.com/t/children-siblings/157536 "2009-01-12T21:44:20Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/6bbea6/32.png) [@Paul\_I](https://www.ruby-forum.com/u/Paul_I)\
**Post date:** [January 12, 2009, 9:44pm UTC](https://www.ruby-forum.com/t/children-siblings/157536/1 "2009-01-12T21:44:20Z")

</div>

Hi,

I’m trying to show a side-menu with a section, so, for example:

- Welcome

- Items Intro  
++ Item A  
++ Item B

I’d like to show a list with “Items Intro, Item A, and Item B” on the  
Items Intro, Item A, and Item B pages- with my current page highlighted.

At present, I’m doing something similar to:

\<r:children:each\>  
\<li \<r:if\_self\> class=“selected”\</r:if\_self\>\<r:unless\_self\>  
class=“item”\</r:unless\_self\>\>  
\<r:title /\>  
  
\</r:children:each\>

But, as soon as I click on Item A, or Item B, they lose the items  
(because those are obviously now siblings of the current page). Is  
there anyway to attempt to find both children and perhaps siblings, or  
a clever way to avoid having to duplicate the items for each page?

Thanks!

Paul

---

<div class="post-metadata">

**Author:** ![Paul\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/6bbea6/32.png) [@Paul\_I](https://www.ruby-forum.com/u/Paul_I)\
**Post date:** [January 12, 2009, 10:06pm UTC](https://www.ruby-forum.com/t/children-siblings/157536/2 "2009-01-12T22:06:50Z")

</div>

On Mon, Jan 12, 2009 at 2:43 PM, Paul I. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Intro, Item A, and Item B pages- with my current page highlighted.

I believe that if you wrap that snippet with \<r:find  
url=“/items-intro/”\>…\</r:find\> you should be good.

~Nate

---

<div class="post-metadata">

**Author:** ![Paul\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/6bbea6/32.png) [@Paul\_I](https://www.ruby-forum.com/u/Paul_I)\
**Post date:** [January 12, 2009, 10:10pm UTC](https://www.ruby-forum.com/t/children-siblings/157536/3 "2009-01-12T22:10:56Z")

</div>

Yep, worked perfectly. Thank you!

---

<div class="post-metadata">

**Author:** ![Paul\_I](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/6bbea6/32.png) [@Paul\_I](https://www.ruby-forum.com/u/Paul_I)\
**Post date:** [January 12, 2009, 10:12pm UTC](https://www.ruby-forum.com/t/children-siblings/157536/4 "2009-01-12T22:12:42Z")

</div>

On 12 Jan 2009, at 20:43, Paul I. wrote:

> \<r:children:each\>
> 
> \<li class="selected" class="item"\>

I think what you need to do is wrap the above section of code in a  
\<r:find/\> tag. If the “Items Intro” has the url: /items you would do  
something like:

\<r:find url=“/items”\>  
\<r:children:each\>  
\<li \<r:if\_self\> class=“selected”\</r:if\_self\>\<r:unless\_self\>  
class=“item”\</r:unless\_self\>\>  
\<r:title /\>  
  
\</r:children:each\>  
\</r:find\>

That way, it will always find the children of the “Items intro” page,  
even if the page you are on _is_ a child of “Items intro”.

You might need to tinker with the if/unless\_self conditions to apply  
the appropriate classes.

If you find yourself wanting to work with sibling pages, instead of  
child pages, then check out the sibling\_tags extension:

[GitHub - nelstrom/radiant-sibling-tags-extension: Allows you to refer to the current page's previous/next sibling.](http://github.com/nelstrom/radiant-sibling-tags-extension/tree/master)

This is useful, for example, if you want to provide “Next” and  
“Previous” links.

Hope this helps,  
Drew
