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.
This patch adds Rules events for hook_ENTITY_view(). As the EntityAPIController already invokes the event, adding the Rules event definition in entity.rules.inc was enough. The event itself works, but I'm still facing problems when using the view mode variable in a data comparison condition (Fatal error: Unsupported operand types in includes/form.inc on line 2525). As this happens for the node view as well, this problem seems to be an Rules issue.
Comment | File | Size | Author |
---|---|---|---|
#4 | entity_rules_view_event3.patch | 1.62 KB | mh86 |
#2 | entity_rules_view_event2.patch | 1.15 KB | mh86 |
entity_rules_view_event.patch | 1011 bytes | mh86 | |
Comments
Comment #1
fagoindeed, options lists for event variables were completely broken in Rules as the wrappers didn't work in that case. I've just fixed that in entity + rules, so the node-view view-modes now work for me in Rules.
To fix the patch we'll need to add something like
to the view-mode variable info array.
Comment #2
mh86 CreditAttribution: mh86 commentedUpdated the patch for the latest Rules fix. Furthermore, the view mode variable will only be added to entities with some view modes.
Comment #3
fagothanks, committed.
Comment #4
mh86 CreditAttribution: mh86 commentedupdated the patch to only expose the view event for entities with view modes. For the other entities we assume that they don't use entity view anyway.
Comment #5
fagothanks, works for me. committed.