• aljrit

    (@aljrit)


    Hi

    Firstly, a great form manager. Only came across it recently but have used on a couple of sites and will certainly use again.

    I have scanned through all the posts and cannot see this raised before – apologies if I missed it…

    I need to display the data in the order of one of the fields. Have given this field a nickname of ‘date’. The field’s format is dd-MON-yy.

    On the page displaying the data I have [formdata courses-1 orderby=”date”]. Only problem is that the order displayed is not correct, it sort of follows the field ‘date’ but not entirely. I assume I am missing a trick here, any and all help really appreciated.

    URL is http://www.trager.co.uk/training-courses/course-details and the field’s label is ‘Start date (DD-Mon-YY)’

    http://wordpress.org/extend/plugins/wordpress-form-manager/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter aljrit

    (@aljrit)

    Think I may have found the problem. The data is displayed in order of day of the month (the first 2 digits of the field). I guess what is needed is a strtotime to get the numerical value of the date and then order by that.

    Only problem is I have little PHP experience and no knowledge of MySQL. So I have no idea how to implement. Do I modify api.php – and if so, then how?

    Any ideas or help would be great.

    Thanks

    Plugin Author hoffcamp

    (@hoffcamp)

    This is a bug. The ‘date’ field is really just a text field, so as far as the code is concerned, its the same as any other. The validation information isn’t really accessible to the query function, since its just a script that runs on the user side.

    The relevant code starts at line 1082 of db.php. You can see there is a hack already for numerical versus text sorting (ASC_N and DESC_N do numerical sort, ASC and DESC do alphabetical). The $orderBy variable stores the MySQL ‘ORDERBY’ clause.

    You can insert the following to get special ‘ASC_D’ and ‘DESC_D’ date sorters for the format you mentioned (dd-MON-yy), after the ‘if’ and before the ‘else’:

    elseif ($ord == 'ASC_D' || $ord == 'DESC_D'){
    		$ord = substr($ord,0,strlen($ord)-2);
    		$orderBy = 'STR_TO_DATE(<code>'.$orderBy.'</code>, \'%d-%b-%y\')';
    }
Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘[Plugin: WordPress Form Manager] Summary Display Order’ is closed to new replies.