Sort By Created Date and Metadata Date Field


(Nick Papadatos) #1

Matrix Version: 5.3

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.

14%20pm

Has anyone been able to get around this?

I hope I have given enough info
Cheers
N


(Emily) #2

Hi Nicky,

Not sure I 100% understand what your current setup is, but hopefully the info I can give will help. :slight_smile:

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).

Did this help?
Any other info you needed?


(Nick Papadatos) #3

Thanks Emily

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:

    %begin_Scitech%
     .
     .
    <time class="news-list__pubdate dt-published">%asset_metadata_pub_date%</time>
      %else_Scitech%
   %begin_News%
    .
    .
    <time class="news-list__pubdate dt-published">%asset_published_readabledate%</time>
     %end_News%
  %end_Scitech%

So when I change the metadata date field from the faculty news item to a date older than the created date the sorting doesn’t work:

When I try and sort by metadata date field it screws up the boarder news etc

Thanks
N


(Emily) #4

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.


(Nick Papadatos) #5

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.

Cheers
N