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.
#1077148: add an entity-view row plugin added a row plugin to display any supported entity in an unformatted view. I suggest we go one step further and implement a views field handler that is able to display the same rendered entity.
We intend to use this on Commerce to display the line items in the cart: line items are arbitrarily complex entities, we only know that some fields are likely to be there (quantity, price, etc.), we would like to use the rendered entity to render the rest of the fields.
Comment | File | Size | Author |
---|---|---|---|
#8 | entity_views_render_1.patch | 12.19 KB | mh86 |
#6 | entity_views_render.patch | 11.68 KB | fago |
#4 | 1209678-views-field-render-entity.patch | 4.29 KB | Damien Tournoud |
#1 | 1209678-views-field-render-entity.patch | 3.96 KB | Damien Tournoud |
Comments
Comment #1
Damien Tournoud CreditAttribution: Damien Tournoud commentedI promised a simple patch. I think it is the case.
Comment #2
fagoheureka!
I didn't knew about the row_index variable! That helps us a lot for #1172970: provide a unified way to retrieve result entities!
We already have the 'entity type' directly in the 'base table', so there is no need to duplicate it on the field-handler level. Let's make use of the 'base table' level key instead too.
Minor, but this shouldn't be there.
Indeed, the patch is rather simple and short :)
Comment #3
drunken monkeySubscribing.
Comment #4
Damien Tournoud CreditAttribution: Damien Tournoud commentedSorry for dropping the ball on this. Here is a new patch that addresses #2.
Comment #5
fagoThanks, looks good. However, in the meantime #1172970: provide a unified way to retrieve result entities got committed - so I think we should make use of the
views_handler_field_entity
provided by views now.Comment #6
fagook, I've updated the patch to work upon that handler + worked over the entity-row plugin too, so it also makes use of the query-backend's entity loading.
Patch attached. Requires #1270890-13: provide a way to provide entity-related views fields to work.
(It turned out the generic entity-handler misses initialization of $this->entity_type)
Comment #7
das-peter CreditAttribution: das-peter commentedsubscribe
Comment #8
mh86 CreditAttribution: mh86 commentedre-rolled patch from #6 for the latest entity api version with following changes:
Changing the name of the row plugin will require a cache clear when updating. In #1330874: Fatal Error Class 'EntityFieldHandlerHelper' not found in entity.views.inc an empty update function has already been added for a similar case, so I think that one should be enough.
Comment #9
fagothanks, committed.
Comment #11
geek-merlinbumping #1796110: Rendered entity fields show same result
by reopening and raising this issue - the handler seems broken for many use cases.
Comment #12
corvus_ch CreditAttribution: corvus_ch commentedWorking is going on in #1796110: Rendered entity fields show same result. I provided a patch there.