Sort order

Archived from the Xataface Users forum.

zopemgr — Mon Apr 24, 2006 6:39 am

Hi Steve

Is there an easy way to default the sort order in list view. For example, I have a set of comments and I’d like them to always start sorted in descending date sequence.

Many thanks

Neil


njw — Mon Apr 24, 2006 7:22 am

For some reason this came up under the wrong name. However, it is from me rather than zopemgr.


shannah — Mon Apr 24, 2006 8:36 am

There is currently no support for sort order in list view. This will be added in version 0.6.0 - early May. Sorry.

-Steve


zopemgr — Tue Apr 25, 2006 3:13 am

No problems - I can cope until then, because the rest is working well!

Cheers

Neil


antg — Tue Oct 24, 2006 8:27 pm

Hi, Just wondering if it’s possible to do this now? I’m running 0.6.9r1 and I need to sort the “list” view by date.

P.S. This program is fantastic!!!!!

Cheers,
Anthony


shannah — Thu Oct 26, 2006 10:41 am

Yes… click on the header for any column and it will sort on that column. Click again and it will sort reverse.

-Steve


antg — Thu Oct 26, 2006 7:23 pm

Hi, Thanks for the reply.
It looks like that only sorts the records which are shown in the query (records 1-30 for example), whereas I would like to sort all of the records by that field.
I would also like it to sort by a certain field by default, but I’m not sure how to go about doing this.

For example, every record has a date in this format 2006-10-27 and I would like it to always show the data sorted by that field unless someone clicks on a different heading.

Is there a way I can get it to do this? My apologies as I (obviously) don’t have a great deal of php / mySql experience, but I’m keen to learn

Thanks again!

Ant.


shannah — Fri Oct 27, 2006 2:06 pm

There is some stale javascript code that causes a javascript sort on the displayed records when you click in the header cell (not on the text). But if you click on the text in the header cell, it will sort all of the records- not just the ones displayed on the page.

Best regards

Steve


generatedname — Wed Mar 14, 2007 2:37 pm

Is it possible to have a default sort mode?

Perhaps by putting the code in index.php?

I’ve been tyring to play around with a block of code towards the top of index.php:

if ( !isset( $_REQUEST[‘-sort’])){
$_REQUEST[‘-sort’] = ‘Firstfield+asc%2C+Secondfield+asc’;
$_GET[‘-sort’] = ‘Firstfield+asc%2C+Secondfield+asc’;
}

this gives me a huge error page….when I comment out the “$_REQUEST[‘-sort’] =” line, the error goes away but it does not function.

Was wondering if there is a way similar to this to set default sorts for list view, for multiple fields.

Thanks,

Kurtis


shannah — Wed Mar 14, 2007 3:39 pm

You have the right idea.Ê You don’t need all the url encoded stuff though:

if ( !isset( $_REQUEST[‘-sort’])){

$_REQUEST[‘-sort’] = ‘Firstfield asc, Secondfield asc’;

$_GET[‘-sort’] = ‘Firstfield asc, Secondfield asc’;

}

And make sure you do this before the call to df_init().

Best regards

Steve


generatedname — Wed Mar 14, 2007 3:47 pm

Thanks a ton steve!

-Kurtis


generatedname — Wed Mar 14, 2007 3:47 pm

Thanks a ton steve!

-Kurtis