Blog Sections Open

Preserving the Manual Order of documents in Ditto

If you pass a manual list of resource IDs into Ditto, you often need to keep that custom order instead of letting default sorting rearrange the results.

Ditto can render an explicit list of documents, but many developers discover that the output order still does not match the order of IDs they passed in. That usually happens because Ditto is still applying its own ordering rules.

Example

[[Ditto? &documents=`91,92,90` &tpl=`services-tpl`]]

The real requirement

You do not want alphabetical or date sorting here. You want the sequence from the &documents parameter itself.

Recommendation

Whenever a listing is hand-curated through explicit IDs, treat that ID order as the primary business rule. Disable or override default sorting accordingly, otherwise the curated sequence is lost.

Newer post

Using MODX API Functions from an External PHP File

If an external PHP script needs MODX or Evolution CMS functions, bootstrap the CMS first instead of trying to call API helpers in isolation.

Older post

Combining autoFilter with request-Based Ditto Sorting and Pagination

When autoFilter and request-based Ditto parameters collide, the clean fix is to separate filtering from sorting concerns instead of trying to force one cached call to do everything.