Sort Code

har7801 11 Oct, 2012
I have used the tutorial for V4 and got the database working well, the tutorial for multi record loading. Now that I am getting a few records, is that a line I can enter into the custom code section that will sort the results by a field (cf_id) in a descending order.

Cheers

Mick.
Max_admin 11 Oct, 2012
Hi Mick,

Please check the "Order Fields" field in the "Multi Record loader" action under the "Data displayer" tab.

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
har7801 13 Nov, 2012
Thanks Heaps,

Is there anyway to reverse the sort order doing that?
GreyHead 13 Nov, 2012
Hi Mick,

I don't think that you can specify ASC or DESC in the DB Multi-Record Loader (I just tried and nothing was ordered). If you aren't using the Data Displayer then you could use a custom Code action to reverse the order of the array. Or you could try adding an extra column to your table and set it to be the negative of the cf_id.

Later: I just looked at the code and there is a workaround.

First you must enable Pagination (I don't quite know why). Then use a Custom Code action before the DB Multi Record Loader and add code like this.
<?php
if ( !isset($form->data['order']) || !$form->data['order'] ) {
  $form->data['order'] = 'cf_id';
  if ( !isset($form->data['direction']) || !$form->data['direction'] ) {
    $form->data['direction'] = 'DESC';
  }
}
?>

Bob

Later still: I added this FAQ
This topic is locked and no more replies can be posted.