I made a custom EntityQuery Block Plugin with a table output and managed to make the headers sortable using this $header definition:

        $header = [
            'title'      => [
                'data'      => t('title'),
                'field'     => 'title',
                'specifier' => 'title',
            'mydate'       => [
                'data'      => t('mydate'),
                'field'     => 'field_date_paragraph',
                'specifier' => 'field_date_paragraph',

Then I added a tablesort when retrieving the nodes:

    $nids = \Drupal::entityQuery('node')
        ->condition('status', 1)
        ->condition('type', 'project')
        ->condition('field_exhibition.target_id', \Drupal::routeMatch()->getRawParameter('node'))

The output looks fine and column headers are clickable - but nothing happens. Actually the GET parameters get correctly added to the URL and look something like:


I think the problem is date field (field_date_paragraph) which is a paragraph field. Inside the paragraph I have a date field and it is this one which should get ordered. What do I have to add to $header definition to make reference to the date field inside field_date_paragraph?

  • How does it know what to sort on?
    – Kevin
    Commented Jan 31, 2019 at 22:41
  • You should also show us the $header definition Commented Feb 1, 2019 at 6:37
  • I added the $header definition. I think the problem is that field_date_paragraph is a paragraph field and inside the paragraph there is the date field which should get ordered.
    – geraldo
    Commented Sep 2, 2020 at 15:18

1 Answer 1


I think you need to specify a filed name inside a paragraph in the header array, like field_date_paragraph.DATE_FIELD_NAME (This behavior is, also supported inside condition method) And here is the issue about lack of documentation https://www.drupal.org/project/drupal/issues/1924622

  • Ok, so I put 'field' => 'field_date_paragraph.field_date', in $header definition, but without any effect. Should I also change the specifier? I tried putting field_date_paragraph.field_date and also field_date, but Drupal gives an error stating Invalid specifier 'field_fecha'.
    – geraldo
    Commented Sep 3, 2020 at 13:25
  • 1
    try with this 'specifier' => array('field' => 'field_name', 'column' => 'value'), also, there are some methods that should help: entityOrderBy propertyOrderBy fieldOrderBy Commented Sep 4, 2020 at 14:16
  • Putting an array as specifier gives an "Array to string conversion" warning in Drupal and follow up errors. Maybe because I don't know how to apply entityOrderBy.
    – geraldo
    Commented Sep 4, 2020 at 16:10
  • Are you sure that you're following the example from the d.org link? $header = array( 'title' => array( 'data' => t('Entity field'), 'type' => 'field', 'specifier' => array('field' => 'field_name', 'column' => 'value'), ), ); Commented Sep 4, 2020 at 19:25
  • Also, check this similar question drupal.stackexchange.com/questions/192757/… Commented Sep 4, 2020 at 19:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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