Re: [Radiant] Next and Previous Articles

2006-09-12 Thread Dave Crossland
On 12/09/06, Sean Santry <[EMAIL PROTECTED]> wrote:
> > There was no radiant/app directory so I've created it and its
> > behaviors child. I now get these errors:
>
> Sorry, Dave, I should have been more clear. In your Radiant
> installation (wherever that is), find the app directory, in which
> there should be a behaviors directory. For example, if you installed
> radiant in /home/dave/foo/radiant-0.5.2, you should put the
> 00_next_previous_behavior.rb in /home/dave/foo/radiant-0.5.2/app/
> behaviors/.

Ah, another issue caused by using the gem installation then.

I'll look into using the SVN version I think :-)

Thanks again!

-- 
Regards,
Dave
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-09-12 Thread Sean Santry
> There was no radiant/app directory so I've created it and its
> behaviors child. I now get these errors:

Sorry, Dave, I should have been more clear. In your Radiant  
installation (wherever that is), find the app directory, in which  
there should be a behaviors directory. For example, if you installed  
radiant in /home/dave/foo/radiant-0.5.2, you should put the  
00_next_previous_behavior.rb in /home/dave/foo/radiant-0.5.2/app/ 
behaviors/.

HTH,

- Sean
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-09-12 Thread Dave Crossland
On 11/09/06, Sean Santry <[EMAIL PROTECTED]> wrote:

Hi Sean,

Thanks for the quick response! :-)

> > If I want to use these behaviours, how do I go about that? :-)
>
> Create a file named "00_next_previous_behavior.rb", paste in the
> code, and save it to your radiant/app/behaviors directory. Then
> restart the app.

There was no radiant/app directory so I've created it and its
behaviors child. I now get these errors:

undefined tag `previous'
undefined tag `next'

Could this work if it was packaged as a plugin?

-- 
Regards,
Dave
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-09-11 Thread Sean Santry

> If I want to use these behaviours, how do I go about that? :-)

Oh, and if you were also wondering how you would actually use the  
tags once you've got the behavior installed, here's an example:




- Sean

___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-09-11 Thread Sean Santry

> If I want to use these behaviours, how do I go about that? :-)

Create a file named "00_next_previous_behavior.rb", paste in the  
code, and save it to your radiant/app/behaviors directory. Then  
restart the app.

HTH,

- Sean
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-09-11 Thread Dave Crossland
On 06/09/06, Sean Santry <[EMAIL PROTECTED]> wrote:
> Here's the corrected version:

If I want to use these behaviours, how do I go about that? :-)

-- 
Regards,
Dave
___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-09-06 Thread Sean Santry
Keith Bingman wrote:

> Not as elegant as John's, but for some reason current.siblings  
> returns an empty array.

FWIW, the problem wasn't that current.siblings was returning null.  
Rather, the problem was that current.siblings returns a list that  
doesn't include the current page [1], so siblings.index(current) was  
returning null. Calling "self_and_siblings" instead of "siblings"  
works fine. Here's the corrected version:

class Behavior::Base

   define_tags do

 tag "next" do |tag|
   current = tag.locals.page
   by = tag.attr['by'] || 'title'
   siblings = current.self_and_siblings.sort_by { |page|  
page.attributes[by] }
   index = siblings.index(current)
   next_page = siblings[index + 1]
   if next_page
 tag.locals.page = next_page
 tag.expand
   end
 end

 tag "previous" do |tag|
   current = tag.locals.page
   by = tag.attr['by'] || 'title'
   siblings = current.self_and_siblings.sort_by { |page|  
page.attributes[by] }
   index = siblings.index(current)
   previous = siblings[index - 1]
   if previous
 tag.locals.page = previous
 tag.expand
   end
 end

   end

end

- Sean

[1] http://ar.rubyonrails.com/classes/ActiveRecord/Acts/Tree/ 
ClassMethods.html

___
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-08-23 Thread Keith Bingman
Ok, I think I have it here. Not as elegant as John's, but for some reason current.siblings returns an empty array. I simply found the page's parent  and then the children, those are siblings, right? I am sure there is a better way to do this, but here is the code:    tag "next_page" do |tag|      current = tag.locals.page      parent = tag.locals.page.parent      by = tag.attr['by'] || 'title'      siblings = parent.children.sort_by { |page| page.attributes[by] }      index = siblings.index(current)      next_page = siblings[index + 1]      if next_page        tag.locals.page = next_page        tag.expand      end    end        tag "prev_page" do |tag|      current = tag.locals.page      parent = tag.locals.page.parent      by = tag.attr['by'] || 'title'      siblings = parent.children.sort_by { |page| page.attributes[by] }      index = siblings.index(current)      prev_page = siblings[index - 1]      if prev_page        tag.locals.page = prev_page        tag.expand      end    endStill has a few problems, like showing the last link on the first page, but these are easily overcome.Keith BingmanOn Aug 23, 2006, at 9:04 AM, Keith Bingman wrote:John, I am having a few problems with this. First of all, 'next' is a reserved word. Changed that to 'next_link', but I am still getting a nil object for siblings. For some reason it is not finding any. This is with Radiant 0.5.2, any help appreiciated.Keith BingmanOn Aug 22, 2006, at 10:46 PM, John W. Long wrote:    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 ___Radiant mailing listRadiant@lists.radiantcms.orghttp://lists.radiantcms.org/mailman/listinfo/radiant ___
Radiant mailing list
Radiant@lists.radiantcms.org
http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-08-23 Thread Keith Bingman
John, I am having a few problems with this. First of all, 'next' is a reserved word. Changed that to 'next_link', but I am still getting a nil object for siblings. For some reason it is not finding any. This is with Radiant 0.5.2, any help appreiciated.Keith BingmanOn Aug 22, 2006, at 10:46 PM, John W. Long wrote:    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 ___
Radiant mailing list
Radiant@lists.radiantcms.org
http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-08-22 Thread Keith Bingman
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@lists.radiantcms.org
> http://lists.radiantcms.org/mailman/listinfo/radiant

___
Radiant mailing list
Radiant@lists.radiantcms.org
http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-08-22 Thread John W. Long
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@lists.radiantcms.org
http://lists.radiantcms.org/mailman/listinfo/radiant


Re: [Radiant] Next and Previous Articles

2006-08-22 Thread John W. Long
Keith Bingman wrote:
> Am I overlooking something, or as it currently stands is it  
> impossible to create links the next article (next Child, in this  
> case)? I need to create something like this for a small part of a  
> site, which is basically done. This is the last thing holding me up...

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

 tag "previous" do |tag|
   current = tag.locals.page
   by = tag.attr['by'] || 'title'
   siblings = current.siblings.sort_by { |page| page.attributes[by] }
   index = siblings.index(current)
   previous = siblings[index - 1]
   if previous
 tag.locals.page = previous
 tag.expand
   end
 end
   end

This would enable you to do something like this:

   

Or even:

   Next >>

The above is completely untested.

--
John Long
http://wiseheartdesign.com
___
Radiant mailing list
Radiant@lists.radiantcms.org
http://lists.radiantcms.org/mailman/listinfo/radiant


[Radiant] Next and Previous Articles

2006-08-22 Thread Keith Bingman
Am I overlooking something, or as it currently stands is it  
impossible to create links the next article (next Child, in this  
case)? I need to create something like this for a small part of a  
site, which is basically done. This is the last thing holding me up...

Keith Bingman
___
Radiant mailing list
Radiant@lists.radiantcms.org
http://lists.radiantcms.org/mailman/listinfo/radiant