I've been following this thread, but haven't replied yet.  The problem may be a tag scoping issue, and maybe a custom tag is in need here.

tag "children:random" do |tag|
  children = tag.locals.children
  if children.size > 0
    index = rand(children.size)
    tag.locals.page = children[index]
    tag.expand
  end
end

Then in your page, write

<r:children:random /><r:title /></r:children:random>

or just
<r:children:random:title />

This will only select one child page, mind you, and would need to be modified to select more than one.

Cheers,

Sean Cribbs
seancribbs.com

On 9/14/06, Erik Mallinson <[EMAIL PROTECTED]> wrote:
Yeah, I wrote that in a rush before leaving work and realized it a few minutes later. Sorry!

Erik

On 9/13/06, Giovanni Intini < [EMAIL PROTECTED]> wrote:
Unfortunately that is the same code I posted :) (except for the limit attribute of random, that doesn't exist).

2006/9/13, Erik Mallinson < [EMAIL PROTECTED] >:
Ah. So something like this? If such a thing would work.

<r:random
limit="1" >

  <r:children:each>
    <r:option><r:title /></r:option>
  </r:children:each>

</r:random>


On 9/13/06, Giovanni Intini < [EMAIL PROTECTED]> wrote:
The code you wrote should grab the title of the first child (in a list made by all the children ordered in ascending order by published_at).

2006/9/13, Erik Mallinson < [EMAIL PROTECTED]>:
Does this work?
<r:children:each limit="1">
  <r:random>
    <r:option><r:title /></r:option>
  </r:random>
</r:children:each>

That would be grabbing one random title from children pages, correct?
I haven't tried it myself, so I might be wrong.


Erik Mallinson


On 9/13/06, Giovanni Intini <[EMAIL PROTECTED]> wrote:
>
> I tried to get a random child's title from a page using this code, but it doesn't work because it gives the title of the current page and not of the child. Is there a way to get a random page?
>
> <r:random>
>   <r:children:each>
>     <r:option><r:title /></r:option>
>   </r:children:each>
> </r:random>
>
>
> _______________________________________________
> Radiant mailing list
> Post:   Radiant@lists.radiantcms.org
> Search: http://radiantcms.org/mailing-list/search/
> Site:   http://lists.radiantcms.org/mailman/listinfo/radiant
>
>
_______________________________________________
Radiant mailing list
Post:   Radiant@lists.radiantcms.org
Search: http://radiantcms.org/mailing-list/search/
Site:   http://lists.radiantcms.org/mailman/listinfo/radiant


_______________________________________________


_______________________________________________


_______________________________________________


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


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

Reply via email to