Navigation and Sub Menus

Guys

I am so close to finishing my first radiant site. Just one last thing
to do
to get things finished. Each of the section in my website has a sub
menu.
Works wonderfully. However, my boss now wants to have further sub
menus.
Here’s the example:-

Who We Are
Our Past
Article One
Article Two
Our Present
Our Future
Our People
Partners
Managers

What my boss wants, is that if the user is in the Our People section or
one
of its children, the following would get shown.

Our Past
Our Present
Our Future
Our People
Partners
Managers

I didn’t think it would be too difficult, so created code using the
r:page:if_url syntax as follows:-

<r:find url="/who-we-are/">

  • <r:page:if_url matches="/our-people/">
    <r:children:each>

  • <r:title />

  • </r:children:each>
    </r:page:if_url>
    </r:children:each>

What this actually produces is

Our Past
Partners
Managers
Our Present
Partners
Managers
Our Future
Partners
Managers
Our People
Partners
Managers

This is only displayed if you are viewing the Our People section. I
have to
be selective about which sections will have further subsections so can’t
simply nest a children:each in another one. I am just having problems
getting round what actually happening in each context.

Does anybody have any suggestions?

Thanks in advance
Regards
Harvey

This e-mail has been scanned for all viruses by MessageLabs.

If nobody has a more specific answer (I don’t have it), I do remember a
similar question being asked here not so long ago. So you might be
helped by the archives.

Regards,
Erik.

Harvey B. schreef:

Article Two

Our Present

Partners simply nest a children:each in another one. I am just having problems _______________________________________________ Radiant mailing list [email protected] http://lists.radiantcms.org/mailman/listinfo/radiant


Erik van Oosten

On 09/08/2006, at 10:50 PM, Harvey B. wrote:

Guys

This is only displayed if you are viewing the Our People section. I
have to
be selective about which sections will have further subsections so
can’t
simply nest a children:each in another one. I am just having problems
getting round what actually happening in each context.

Does anybody have any suggestions?

I had the same problem, I ended up implementing two custom tags:

Behavior::Base.define_child_tags do
tag ‘if_current_page’ do |tag|
if tag.locals.page == tag.globals.page
tag.expand
end
end

tag ‘if_current_parent’ do |tag|
potential_parent = tag.locals.page
child = tag.globals.page
if child.child_of? potential_parent
tag.expand
end
end
end

I also patched Page to add Page#child_of? (used in
<r:if_current_parent>) but you could do it inline.

Then in my navigation snippet I used these to conditionally show the
children/siblings of the page in question…

For some reason I needed to use #define_child_tags rather than
#define_tags, as the custom tags wouldn’t be available in pages with a
custom behaviour. John, if you read this, would you be able to take a
second and explain why? (I couldn’t quite figure it out going through
the code)

Bodhi

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs