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.
Would be lovely to use node type conditions with negation.
Example: show title and/or navigation block on all but 1-2 node types.
Doing this "right" would mean another option in context_condition_node.inc
Here's a quick plugin to get the job done, but a real patch would be better.
Comments
Comment #1
tr33m4n CreditAttribution: tr33m4n commentedSubscribe, would love to see this for practically all the conditions tbh
Comment #2
grasmash CreditAttribution: grasmash commentedAdding option to node condition to allow negation.
Comment #3
grasmash CreditAttribution: grasmash commentedComment #4
doublejosh CreditAttribution: doublejosh commentedI've been using this in production ever since the patch was posted in 2012.
Comment #5
grasmash CreditAttribution: grasmash commentedI'm also using this in production successfully. @doublejosh, please move to RTBC if you agree that patch is reviewed, tested, and ready to be committed.
Comment #6
doublejosh CreditAttribution: doublejosh commentedDone.
Comment #7
doublejosh CreditAttribution: doublejosh commentedHere's a more recent version that fires more widely. Because views and other callback pages are also not that given node type.
Comment #8
doublejosh CreditAttribution: doublejosh commentedI take it back, the negation code listed here is not working as intended. Should be a smart fix though.
Comment #9
grasmash CreditAttribution: grasmash commented@doublejosh Can you be more specific? Is the patch in #3 not working? In what way?
Comment #10
grasmash CreditAttribution: grasmash commentedI'm moving this back to 'Needs Review' because I cannot reproduce the issue referenced by @doublejosh.
Comment #11
jantoine CreditAttribution: jantoine as a volunteer commentedI was able to reproduce @doublejosh's issue by trying to have a context active on a non-node page using the negation functionality. This doesn't work is because the context_node_condition() is invoked from hook_node_view() and hook_form_alter(), so it's only fired when a node is being viewed/edited. The attached patch moves the invocation from hook_node_view() and hook_node_alter() to hook_init() where many other context conditions are invoked from.