Ted Vinke <[EMAIL PROTECTED]> wrote:
> Hi!
>
> I need to select a series of persons who have been born in this month and
> show them ordered by their birthday.
>
> I've stored the birthday as a LONG in the person builder, but
> unfortunately the following constructions sorts the persons by the
> *entire* birthday.
>
> <mm:list
> path="person"
> fields="person.firstname,person.lastname,person.birthday"
> orderby="person.birthday"
> >
>
> Is there a way to sort by another date-component instead of year, such as
> the day of the month? Is there an easy MMBase wat of doing this, or would
> I have to use scriptlets to add all these persons to a Vector first and
> then somehow sort it by day?
It is a hard problem, and one of the reasons why we need a date-field.
Of course you don't use Vectors but ArrayLists (no need synchronizing).
Furthermore you can use the 'jspvar' attribute of the list, so you don't
need creating the vector yourself.
(
<mm:listnodes id="list" ... jspvar="list" />
<% filterBirthDay(list); ....%>
<mm:listnodes referid="list">
...
</mm:listnodes>
)
My code for the same problem once upon a time looked something like this:
<mm:time id="today" time="now" format="MM-dd" write="false" />
<mm:listnodescontainer path="people">
<mm:sortorder field="firstname" />
<mm:listnodes id="person">
<mm:field name="birthdate">
<mm:time format="MM-dd">
<mm:compare referid2="today">
<a href="<mm:url id="shown" referids="person"
page="index.jsp?template=smoel.template" />"><mm:field name="firstname" /> <mm:field
name="middle" /> <mm:field name="lastname" /></a><br />
</mm:compare>
</mm:time>
</mm:field>
</mm:listnodes>
</mm:listnodescontainer>
But grantedly, it sucks, and you should hope not to have very many people.
Michiel
--
Michiel Meeuwissen
Mediacentrum 140 H'sum
+31 (0)35 6772979
nl_NL eo_XX en_US
mihxil'
[] ()