Closed (fixed)
Project:
Context
Version:
6.x-3.0
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
9 Nov 2010 at 17:34 UTC
Updated:
7 Dec 2020 at 18:45 UTC
Jump to comment: Most recent
How would I go about integrating a path condition into my module? I've tried putting it in mymodule_init() but context_active_contexts() called there doesn't return any contexts. I have successfully integrated the path condition into a hard-coded menu item in my module, where context_active_contexts() returns the expected contexts when I hit that path (and path is defined in the GUI). However, I'd like users to be able to define any arbitraty path in Context's admin GUI.
I've integrated checks for node conditions into mymodule_nodeapi(), I just can't figure out where the best place to check for path conditions is.
Comments
Comment #1
markj commentedAfter a bit more experimenting, I adjusted the weight of my module to 50 and now context_active_contexts() works in hook_init(), so I can use hook_init() in my module as an integration point. I took a hint from the comment "This should be run at a late stage of the page load to ensure that relevant contexts have been set." in the context_active_contexts() function definition in context.module.
Comment #2
ymakux commentedI faced the same problem for d7. It's better idea to not use hook_init at all, use hook_context_page_reaction() instead
Code sample
Comment #3
paulocsThanks. Closing issue!
Comment #4
paulocsComment #5
paulocs