Unable to sort Express list by date attribute
Permalink
V 8.4.2
The date order of the list appears to neither by asc or desc, just in unsorted order. What am I missing or is this a bug? About 700 Express entries in the list in case that makes any difference.
$calendar = Express::getObjectByHandle('dblsession'); $list = new \Concrete\Core\Express\EntryList($calendar); if($datesort !== 'desc') { // todo this doesnt work $list->sortBySessionDate(); // asc } else { $list->sortBySessionDate('desc'); }
The date order of the list appears to neither by asc or desc, just in unsorted order. What am I missing or is this a bug? About 700 Express entries in the list in case that makes any difference.
That actually throws an error during getResults() for SessionDate or session_date (the actual attribute handle), which seems wrong?
"An exception occurred while executing 'SELECT e.exEntryID, session_date FROM ExpressEntityEntries e LEFT JOIN DblsessionExpressSearchIndexAttributes ea ON e.exEntryID = ea.exEntryID WHERE e.exEntryEntityID = ? ORDER BY session_date desc' with params ["75615924-9963-11e8-8a1a-083e8ebfcaa9"]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'session_date' in 'field list'"
Yet session_date clearly is the attrib handle (see attached)
"An exception occurred while executing 'SELECT e.exEntryID, session_date FROM ExpressEntityEntries e LEFT JOIN DblsessionExpressSearchIndexAttributes ea ON e.exEntryID = ea.exEntryID WHERE e.exEntryEntityID = ? ORDER BY session_date desc' with params ["75615924-9963-11e8-8a1a-083e8ebfcaa9"]: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'session_date' in 'field list'"
Yet session_date clearly is the attrib handle (see attached)
Try
$list->sortBy('ea.ak_session_date', 'desc');
Nope, same unordered output :/
Some ideas:
- Inspect the contents of the DblsessionExpressSearchIndexAttributes table.
- Get the query from the $list object an try to run it manually.
If the search index attribute table is empty, or not up to date, it's because entries need to be 'indexed'.
- Inspect the contents of the DblsessionExpressSearchIndexAttributes table.
- Get the query from the $list object an try to run it manually.
If the search index attribute table is empty, or not up to date, it's because entries need to be 'indexed'.
I think if it's got us THIS stumped it needs a bug report ;)
I'll sort in PHP after the fact, during output
I'll sort in PHP after the fact, during output
Yes, please! If you can describe an MCVE (https://stackoverflow.com/help/mcve), that would be great to document on GitHub:https://github.com/concrete5/concrete5/issues...
https://documentation.concrete5.org/api/8.3.0/Concrete/Core/Express/...