0

I have a custom entity type that uses an entity reference revisions field that accepts multiple values. The referenced paragraphs contain a date field. I would like to sort the entities (descending) by the most recent date in a paragraph referenced from their fields. E.g.:

  • Entity 1

    • Paragraph 0
      • Date: 1/1/2016
    • Paragraph 1
      • Date: 1/1/2017
    • Paragraph 2
      • Date: 1/1/2018
  • Entity 2

    • Paragraph 0
      • Date: 2/1/2017
    • Paragraph 1
      • Date: 2/1/2018
  • Entity 3

    • Paragraph 0
      • Date: 3/1/2016
    • Paragraph 1
      • Date: 3/1/2017

...should sort to: Node 2, Node 1, Node 3.

Thanks!

0

Sounds like you need to do a relationship to the paragraph reference field on your node. Which will then open up the fields on the paragraph into views. Then you might need to turn the field aggregation on in your view and add a sort on your date field selecting the MAX value

  • I did try that. I can then add the date field to each row, but I get multiple rows, one for each paragraph value. Turning on aggregation throws errors: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'node__field_url.field_url_' in 'field list': SELECT DISTINCT node__field_url.field_url_ AS node__field_url_field_url_, (etc.) -- field_url does exist in the view, and displays as expected when aggregation is turned off. – WRD Sep 5 '18 at 13:26
  • Sounds like you're using a field called "Url" in the view and you need to change the aggragation type to one of the other options for that field as some of them for certain fields will cause that error. Or are you saying you have no field with the machine in "url" in your view? If so that's strange and not sure whats going on – Leigh Sep 5 '18 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.