Support the project

If you appreciate what the Tesseract project does for you, consider donating to it.


Fine tuning the ordering

By: François Suter

This latest release of Tesseract components introduces some fine-grained tuning for managing the ordering of data.

Ordering records coming from the TYPO3 database (as retrieved by dataquery, for example) is no trivial task when using translations due to TYPO3's usage of overlays. For example, it is impossible to sort translated records alphabetically by simply applying an order condition to a SQL statement, as that statement is supposed to get the records in the default language and overlay these with translations afterwards.

Extension dataquery tries to be smart about this and apply ordering after overlays when it guesses that it should be so. Indeed dataquery tries to guess if a given field used for ordering is a text field or not (by analyzing the field's TCA definition). If the query relies only on numeric fields for ordering, dataquery assesses that it is safe to order on the SQL query, which is faster and thus should be preferred whenever possible.

This automated guessing proved too restrictive in some situations, in particular when said numeric fields could have different values in translations. Think date and time fields. It appeared necessary to be able to force a given field to be handled on the provider side and not in SQL (or some other place for different Data Providers). Thus a new ordering parameter was introduced in filters called "engine". It may take either "source" or "provider" as a value. With "source" the order condition is expected to be applied in the source query language of the provider, with "engine" it should be applied at a later stage, after translations have been applied.

A filter may now look like:


field = tt_news.datetime
order = desc
engine = provider


Some additional considerations:

  • if a single ordering item is pushed to the "provider" all the ordering will take place after overlays, no matter where other fields might have applied
  • when handling default languages, ordering is always applied to the source, the "engine" property is not taken into account
  • all of this applies to language overlays, not to workspace overlays, so ordering might still be wrong in workspace previews in some special cases

Additional cleanup

In addition to that, the parsing of the ordering configuration in datafilter was improved to be a bit more flexible. It will allow for blank lines, duplicate entries and report errors where appropriate rather than returning non-sense.