Forum: Radiant CMS Children + Siblings

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
2b12a2b9005888970991afc5b3725216?d=identicon&s=25 Paul Ingles (Guest)
on 2009-01-12 21:44
(Received via mailing list)
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>>
       <a href="<r:url/>"><r:title /></a>
     </li>
</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
3c415075c9e778e2d38ebf4588a68464?d=identicon&s=25 Nate Turnage (Guest)
on 2009-01-12 22:06
(Received via mailing list)
On Mon, Jan 12, 2009 at 2:43 PM, Paul Ingles <pingles@me.com> 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
2b12a2b9005888970991afc5b3725216?d=identicon&s=25 Paul Ingles (Guest)
on 2009-01-12 22:10
(Received via mailing list)
Yep, worked perfectly. Thank you!
514784888f1bbfb08a189684bf14abc2?d=identicon&s=25 Andrew Neil (Guest)
on 2009-01-12 22:12
(Received via mailing list)
On 12 Jan 2009, at 20:43, Paul Ingles wrote:
>
>
> <r:children:each>
>    <li <r:if_self> class="selected"</r:if_self><r:unless_self>
> class="item"</r:unless_self>>
>      <a href="<r:url/>"><r:title /></a>
>    </li>
> </r:children:each>

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>>
         <a href="<r:url/>"><r:title /></a>
       </li>
    </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:

  http://github.com/nelstrom/radiant-sibling-tags-ex...

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

Hope this helps,
Drew
This topic is locked and can not be replied to.