Is it a bug or intentional that <r:children:first> and <r:children:last>
disagree with <r:children:each> about the first and last child by
default in Radiant 0.50?
The :first and :last tags appear to return the same thing shown in the
list of pages; that is, children sorted in alphabetical order by page
title, irrespective of order of page creation. This isn’t what I
expected. Meanwhile, <r:children:each> returns them in creation order,
which is more or less what I expected.
I presume the order can be modified in the :each case using the
‘by=“attribute”’ feature, though I’m not entirely clear on what values
are allowed for “attribute” [1]. It might be nice, though, if the
default setting matched the behaviour of :first and :last. It’d also
make more sense (to me at least) if :first really was the first child I
created - can this be selected somehow, or is it hard-wired to sorting
by title?
A cool future feature would allow “by” and “status” selectors on the
:first and :last tags, assuming they’re not already supported.
[1] Indeed there are hints in the source code that <r:title />,
<r:url /> and so-on are part of a wider, general set of attributes
but I don’t know where the list of these attributes is held yet, if
indeed there is a list rather than some kind of run-time definition
mechanism.
Is it a bug or intentional that <r:children:first> and <r:children:last>
disagree with <r:children:each> about the first and last child by
default in Radiant 0.50?
Ug. That would be a bug. I’ve been meaning to rewrite these tags to
simply call out to children each with limit="1", but haven’t gotten
around to it. Please submit a ticket and associate it with the next
release.
The :first and :last tags appear to return the same thing shown in the
list of pages; that is, children sorted in alphabetical order by page
title, irrespective of order of page creation. This isn’t what I
expected. Meanwhile, <r:children:each> returns them in creation order,
which is more or less what I expected.
It’s actually by the published_at field.
I presume the order can be modified in the :each case using the
‘by=“attribute”’ feature, though I’m not entirely clear on what values
are allowed for “attribute” [1].
You can use any attribute with is a column on the pages table. The
<r:children:each /> tag just does a regular SQL query.
It might be nice, though, if the
default setting matched the behaviour of :first and :last. It’d also
make more sense (to me at least) if :first really was the first child I
created - can this be selected somehow, or is it hard-wired to sorting
by title?
<r:first /> and <r:last /> should use <r:children:each /> as their
implementation. As such they should also support the by="attribute"
syntax.
A cool future feature would allow “by” and “status” selectors on the
:first and :last tags, assuming they’re not already supported.
Yah, a status attribute would be good as well. Anyone have time to write
a patch?