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.
I am using views, and I would like to display realnames as one of the columns (fields). I did not see realnames as an option, so I decided to try User: Name as the field to display.
Fortunately, for me, this does show realnames in the column as I had hoped.
But unfortunately for me, even though it shows realnames, when I clicksort the column, it sorts by the username, not the realname, so the shown names no longer look sorted.
I would like to display realnames, but have the clicksort sort by the realnames.
Where have I gone wrong?
Comments
Comment #1
iprosp CreditAttribution: iprosp commentedI was looking for it myself and i solved it by adding in sorting:
profile:General:NAME asc
Where NAME is the name that i gave to the realname field.
General is the profile category.
Don't forget to remove the sorting by username.
Hope it helps!
Comment #2
dpatte CreditAttribution: dpatte commentedThank you, but unfortunately I also tried that, but my realname is composed of two profile fields:
Profile: User Information: First Name and
Profile: User Information: Last Name
In the view I have tried to get both fields, but that makes two fields and I want to sort on the composed realname, not just the first name or just the lastname. I have also tried getting both fields and hiding one while rewriting the other to show both, but it still only sorts by the original value of the part of the name I re-wrote.
I want to sort on the composed realname I have specified in the realname module that is made up of the first and lastname fields, and which it sems to show elsewhere on the site quite well.
Comment #3
iprosp CreditAttribution: iprosp commentedWhat if you tried to use views calc instead? You could create a new calculation(concatenating the two fields), which would create a new field. Then you could add the new field Views Calc: NewFieldName which views will see as one field from the beggining and then you probably would be able to use it as any other field.
Comment #4
nmalinoski CreditAttribution: nmalinoski commentedThis issue is affecting me on the People page (User listing, Drupal core) with Real Name 7.x-1.2; sorting by Username sorts by username while displaying the Real Name override.
Edit: Oops; missed that this is Views-specific.
Comment #5
hass CreditAttribution: hass commentedComment #6
NWOM CreditAttribution: NWOM commentedI am having the same issue as described in #2 with the newest dev for drupal 7. Has anyone found a workaround for this in the meantime?
Comment #7
marco.b CreditAttribution: marco.b as a volunteer commentedAs a workaround for correct sorting in views I recommend to use the user:realname field instead of user:name. this works for me.
Comment #8
NWOM CreditAttribution: NWOM commentedI managed to fix my issue as well when it comes to Search API indexed views. After applying #2512394: Add realname property getter callback to user entity, it was possible to index the Realname of the field. After having the realname indexed, it was possible to add the user:realname to the Search API view as well (similar to #7).