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

> Guys

<snip>

> 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

_______________________________________________
Radiant mailing list
[email protected]
http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to