Hi squiz folk,
Is there way to sort by Created Date and a Metadata Date field values form a single search asset?
I essentially have an Search asset pointing to two locations. 1 broad news and 2 faculty news
1 - faculty news managed via the %asset_published_readabledate% keyword
2 - broad news has the %asset_metadata_pub_date% keyword
The search asset default format %asset_contents_paint_xxxx% the paint layout sorts the layout between the two locations via conditions.
When I change the date via the metadata to one of the root node assets (to a date earlier from the other root node assets) the order doesn’t change.
Not sure I 100% understand what your current setup is, but hopefully the info I can give will help.
Is there way to sort by Created Date and a Metadata Date field values form a single search asset?
You can set the “sort by” options (including the default sort) on the “Asset Sorting” screen - as a Backend editor. There are options for both “when the asset was created” (first dropdown box, in my 5.5 version), and “By metadata field value”.
For news items, I usually have a Metadata field for “published date”, which defaults to the created date unless altered in the metadata. This allows Simple Edit / Edit+ editors to update the metadata field to change the Published date (e.g. if creating the article in advance of publication, and setting a Future Status to go Live).
These “Sort by” rules will apply to all assets in the search results (i.e. all root node locations).
I’m pretty familiar with what you proposed. The issue is that the “broader news” doesn’t have a metadata date field (legacy too late to change) but the specific faculty news does. My paint layout has the following condition:
Ah, I think I understand more now. So it is more the issue of combining the 2 different “sort by” into one singular list?
Can a metadata field (text field) be cascaded onto the older news items, with a default value of %asset_published_readabledate%, and then the faculty-news root node have this same field cascaded down with the keyword %asset_metadata_pub_date% ?
Or are the news stories intertwined under the same root node(s)?
i.e. you will end up with a single metadata field to “sort by” in the Search (or asset listings), but the value that it holds will be set depending on whether its the older/broader news, or the faculty news.
This is just off the top of my head.
Of course Javascript could be written to manually sort the results after Matrix delivers them, but the beauty of Matrix is that often we can avoid this double-process.
I’ll keep mulling it over while I’m out this evening, and if anything more robust comes to mind I’ll let you know. I’m sure some of the Squiz staff would have some tricks they’ve used before.
So it is more the issue of combining the 2 different “sort by” into one singular list?
Correct. There’s more than one root node and this request is more of an isolated one. So not worth the effort to add the metadata date field but would in the near future if we’re going to update the news section. Is’ a shame the search and asst listings assets don’t have multiple sort by i.e readabledate and or other.
Have you tried using the Sort By Asset Keyword Value field and putting a keyword there that prints the metadata field if it has one, if not, prints the published date?
Might have to make the keywords output in ISO format or as a timestamp as the search page will only sort by alphabetical order on that field, it doesn’t know anything about dates.
It may be a limitation of that version of Matrix, as it’s quite old now and I have feeling it might have been fixed since then.
The only other thing I can think of is to add that extra metadata text field to both assets that tries to reference the other metadata field and if it doesn’t exist, print the published date, something like:
%metadata-F_^empty:{asset_published_U}%
Not sure if that will work though again in that version, or if Matrix will complain and throw errors if you use %metadata-F_% on a metadata screen where that field ID def doesn’t exist.