CMS Sorting based on if X exists

Is there a way to get the CMS to sort items based on a date override, and if that override doesn’t exist, then sort by the creation date? We transferred our old website to Webflow, and when we imported our CMS items, they were all given the same creation date even though the source CSV file had specific dates in the CREATION_DATE field.

Since Webflow doesn’t allow a user to change the creation date (another frustration for another day) then we had to add a date override field to handle the old CMS items. The problem is that all new items added to the CMS aren’t sorting by creation date even if no override is set in the CMS.

image

Is there any way to tell the CMS to sort by X but only if a value exists for X, and if not, then sort by Y?

In this case, X = date override, Y = creation date. I told the CMS to sort in that order, but it’s still sorting by the override even if no date exists there so new CMS items are appearing last in the list.

Despite the names, the created, published, and updated date fields are fairly useless for any practical purpose. There are too many scenarios in which the internal publishing mechanisms overwrite them. Just create your own fields, and fully populate them, including the new items you’re adding, your life will be much easier.

What you’re wanting is a coalesce feature, e.g. sort by ( publish-date ?? create-date ). No, the CMS doesn’t support any form of querying.

If you want to hack this;

  • Create two collection lists
    • List one contains only items with a Publish Date Override
    • List two contains only items without a Publish Date Override
  • Use FS combine and FS sort to merge and sort them

Will likely require a small bit of JS to trigger the initial sort on load.