On 30 Aug 2008, at 18:25, Sean Cribbs wrote:

Maybe a simple tag is in order here:

<r:sibling slug="hash"><r:link/></r:sibling>

Where the sibling tag is defined as:

tag 'sibling' do |tag|
tag.locals.page = tag.locals.page.siblings.find {|s| s.slug == tag.attr['slug'] };
tag.expand if tag.locals.page
end

If you want (or can settle for) all of the sibling links, use <r:parent:children:each>.

I've just been working on an extension for accessing neighbouring sibling pages[1], and I found that the following does not work:

tag.locals.page.siblings.find(...)

when you call find() on the siblings, you are actually calling the method from Ruby's enumerable module, rather than from ActiveRecord::Base. So in actual fact, it is necessary to call instead:

tag.locals.page.parent.children.find(...)

which still uses ActiveRecord::Base.find(). If you need to exclude the current page from the result set, you could do so by passing a condition:

:conditions => ["id != ?", tag.locals.page.id]

or something similar. There was a discussion on why find() behaves differently in each situation a few days ago, but it was on the [Radiant-dev] list (google groups).

Drew

[1]:http://github.com/nelstrom/radiant-sibling-tags-extension/tree/master
_______________________________________________
Radiant mailing list
Post:   Radiant@radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant

Reply via email to