[Radiant] Next and Previous Articles

Keith Bingman keith at keithbingman.com
Tue Aug 22 16:39:02 CDT 2006


Thanks John, I will give that a try.

Keith

On Aug 22, 2006, at 10:46 PM, John W. Long wrote:

> John W. Long wrote:
>> Something like this might work for you:
>>
>>    Behavior::Base.define_tags do
>>      tag "next" do |tag|
>>        current = tag.locals.page
>>        siblings = current.siblings.sort_by { |page| page.title }
>>        index = siblings.index(current)
>>        next = siblings[index + 1]
>>        if next
>>          tag.locals.page = next
>>          tag.expand
>>        end
>>      end
>
> The definition for next should be:
>
>     tag "next" do |tag|
>       current = tag.locals.page
>       by = tag.attr['by'] || 'title'
>       siblings = current.siblings.sort_by { |page| page.attributes 
> [by] }
>       index = siblings.index(current)
>       next = siblings[index + 1]
>       if next
>         tag.locals.page = next
>         tag.expand
>       end
>     end
>
> --
> John Long
> http://wiseheartdesign.com
> _______________________________________________
> Radiant mailing list
> Radiant at lists.radiantcms.org
> http://lists.radiantcms.org/mailman/listinfo/radiant




More information about the Radiant mailing list