Listing first and last children

Hi,

On one of my sites, I’m using the following snippet:

<r:children>

<r:first order=“desc”>


<r:snippet name=“entry”/>

</r:first>

<r:each order=“desc” limit=“3” offset=“1”>


<r:snippet name=“entry”/>

</r:each>

<r:last order=“desc” limit=“5”>


<r:snippet name=“entry”/>

</r:last>

</r:children>

The idea is that it should list the 5 most recent entries (child
pages), wrapping each in a div.entry, except adding
class=“firstentry” or “lastentry” to the first and last. I need these
extra handles for the sake of CSS styling, which differs on first/
last from middle entries.

The snippet above works fine, except when I have less than 5 child
pages. In that case, the final entry is listed twice. This won’t be a
problem in the future, when the site grows, but it is an irritation
at this early stage where some of the pages calling this snippet have
less than 5 pages. I wonder if anyone can suggest an improvement?

Thanks,

Drew

Maybe using something like:

<r:children>
<r:each order=“desc” limit=“1” offset=“0”>

</r:each>
<r:each order=“desc” limit=“3” offset=“1”>

</r:each>
<r:each order=“desc” limit=“1” offset=“4”>

</r:each>
</r:children>

In this case <r:each> should return an empty list in the last case.

/AITOR