Sorting in the Entity Query

Created on 1 July 2021, about 4 years ago

Is there a way to sort by draggable views order in the entity query?

πŸ’¬ Support request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡ΊπŸ‡ΈUnited States dealancer Washington D.C.

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States alieffring

    It is a cool thing to do! I ended up following this guide: https://medium.com/@pankajsachdeva_76544/join-tables-using-entityquery-drupal-2599edc9b343

    And my hook_query_TAG_alter() hook ended up looking like this:

    /**
     * Implements hook_query_TAG_alter().
     */
    function mymodule_query_TAG_alter(AlterableInterface $query) {
      $query->addJoin('LEFT', 'draggableviews_structure', 'ds', '[ds].[entity_id] = [base_table].[id]');
      $query->orderBy('ds.weight', 'DESC');
    }
    
    
Production build 0.71.5 2024