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.
When using a Views argument based on an entityref field it would be useful to be able to use the entity label in the views title using argument title substitution.
Comments
Comment #1
joachim CreditAttribution: joachim commentedHere's a patch, modelled on the Views handlers for term arguments.
Comment #3
joachim CreditAttribution: joachim commentedHelps if I roll against HEAD...
Changed the handler class name to be consistent with views classes already there.
Comment #4
joachim CreditAttribution: joachim commented#3: 1588574-2.entityreference.views-argument-handler-title.patch queued for re-testing.
Comment #5
Damien Tournoud CreditAttribution: Damien Tournoud commentedCan you explain what this does? It's fairly not obvious.
This is the menu loader function... you want entity_load_single().
Comment #6
joachim CreditAttribution: joachim commentedWhen you use a Views argument with a numeric value such as a taxonomy term tid, you can have the term's label in the title set by the argument.
Currently, with entref, you just get the ID.
Comment #7
joachim CreditAttribution: joachim commentedThis bit:
With a taxo term ref argument, %1 gets you the term label.
With an entref field, you get just the entity ID.
This patch fixes that.
Comment #8
joachim CreditAttribution: joachim commentedFixed the entity loading.
Comment #9
rocketeerbkw CreditAttribution: rocketeerbkw commented#8 is working for me when referencing Nodes or Users
Comment #10
amitaibuCan't we entity_load() all entities at-once?
Comment #11
joachim CreditAttribution: joachim commentedYeah fair point.
Comment #12
juves CreditAttribution: juves commentedThat's exactly what I need, thanks!
Comment #13
juves CreditAttribution: juves commentedReference field as a context filter (as summary) in view-attachment is still shown as id
Comment #14
joachim CreditAttribution: joachim commentedHere's a patch with comment 10 addressed.
I'm not sure about comment 13. I suspect views summaries use something else in the argument handler to get the title?
Comment #15
jhedstromThis looks good to me. Fixes an issue where the views_data_export module wasn't outputting the downloaded filename properly (entity ID instead of entity title, but with this patch, the title is properly output instead of the ID).