For the context_uuid_condition, the current entity is loaded via menu_get_object()
in order to check if the entity is the one specified for the condition.
This is a clean approach, but with limitations. For instance, I've got a site with a page View that overrides the path for taxonomy terms, which means that menu_get_object()
doesn't return an entity.
In order to circumvent this, we need to load the current menu item based on the path, and information about the entity type. This will provide us with enough information to check if the path is displaying the entity in question, and if the UUID matches.
Comment | File | Size | Author |
---|---|---|---|
#1 | context_uuid-dont_use_menu_get_object-2154693-1.patch | 2.05 KB | olofbokedal |
Comments
Comment #1
olofbokedal CreditAttribution: olofbokedal commentedTested with a taxonomy term which works as intended. Probably needs some more testing for other entities.
Comment #2
skwashd CreditAttribution: skwashd at Dave Hall Consulting commentedIn your example use case you are no longer viewing an entity, you are viewing a view. Looking at this code it adds a fair bit of processing overhead on every page load to check if someone is trying to access a view that overrides an entity list page. I would suggest that you create a new module that extends the
context_uuid_condition
class with your own implementation ofexecute()
.Comment #3
skwashd CreditAttribution: skwashd at Dave Hall Consulting commented