[ic] sort option

Stefan Hornburg Racke interchange-users@interchange.redhat.com
Fri May 24 15:36:01 2002


Paul Jordan <paul@gishnetwork.com> writes:

> Hi
> 
> I need to "force" sort a field.
> 
> [loop search="
>          st=db
>          sf=year
>          [if !cgi mv_arg]
>          se=2002
>          [else]
>          se=[cgi mv_arg]
>          [/else]
>          [/if]
>          em=yes
>          ml=30
>          tf=month,day
>  "]
> 
> 
> [loop-change 1][condition][loop-field month][/condition]
> 
> The problem is that the data in the month field sort alphabetically. I can
> add a control column to associate a number with the month but that doesn't
> seem very clever.
> 
> Is there a way to create a argument to sort by ie:
> 
> tf=month arg="January,February,March......"
> 
> Any Ideas?

I suggest to revise your database structure. You can store the date as seconds
since epoch or in a SQL native format. In the former case use the [tag time]
function, in the latter use [query sql=""] and the functions provided
by SQL database for converting dates/times.

Ciao
        Racke

-- 
Free resources for Interchange programming NOW !!! 
Don't hesitate to contact me if you need my professional help.
Your core developer and consultant for the most sophisticated,
flexible and extensible Open Source eCommerce software.