Forums / Setup & design / Sort by Date not working

Sort by Date not working

Author Message

Ashley Knowles

Monday 17 April 2006 8:16:32 pm

I have a file listing setup, however, I cannot get it to sort by date (correctly)

Below is the code I am trying to use. As you can see, I have a custom attribute called "upload_date", an ezdate field, which is to be sorted in reverse chronological order (i.e. newest first). The code below, however, does not output anything.

{let children=fetch( content, list, hash( parent_node_id, 77,
                                    sort_by, array(upload_date, false(), 191),
                                    limit, 5,
                                    class_filter_type, include,
                                    class_filter_array, array( 'file' ) ) )}

Using this code, I get some output, but the files are not sorted (correctly?).

{let children=fetch( content, list, hash( parent_node_id, 77,
                                    sort_by, $node.data_map.upload_date,
                                    limit, 5,
                                    class_filter_type, include,
                                    class_filter_array, array( 'file' ) ) )}

I have tried substituting $node.data_map.upload_date with $node.data_map.upload_date.data_int, but also no luck.

Am I missing something???

Ɓukasz Serwatka

Monday 17 April 2006 11:17:19 pm

Hi Ashley,

Right syntax for attribute sorting will be:

sort_by, array( 'attribute', false(), 'yourclassid/upload_date'  )

 

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Ashley Knowles

Monday 17 April 2006 11:24:55 pm

That did the trick. Thanks :)