Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Rosencruez on
I was wondering if anyone else ran into this problem. I have a view set up and one of the fields is a list of names (and the field type is an entity reference). When I try to sort it, I notice that it's not in alphabetical order like I expected, but actually in node ID. Is there a way to fix this?
Comments
Relationship on reference field
Instead of showing and sorting on reference field, create a Relationship in Views (under Advanced) on the reference field. Then you can add the Content: Title (make sure to use the relationship). Then sort on the same field.
More Clarification
In this view, I have 2 fields being displayed: the title, and the entity reference field in question. When I sort by title, it works fine and sorts alphabetically (Homer, Max, Stan). When I try to sort the entity reference, it does not sort alphabetically, but instead by node ID (Clifford, Jake, Betty).
Going with spovlot's suggestion, I tried creating relationships concerning the entity reference. I found 2 entries that looked like they would be useful: (Entity Reference: Referenced Entity) and (Entity Reference: Referencing Entity). I tried creating those relationships and applying it to the current fields I have, but that only makes those fields disappear. I'm not sure what I'm doing wrong...
EDIT: I figured it out, spovlot was right the whole time.
Glad you got it
Glad you got it working.
Scott
Could you explain is to me?
Could you explain is to me?
I have an entity reference with 2 fields; node title and term reference (field_company_type)
I want to sort by term reference.
Do I add a relationship to field_company_type, then what do I sort by?