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

markj’s picture

After 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.

ymakux’s picture

I 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

function mymodule_context_page_reaction() {
  if (module_exists('context')) {
    if ($plugin = context_get_plugin('reaction', 'myreaction')) {
      $plugin->execute();
    }
  }
}
paulocs’s picture

Issue summary: View changes

Thanks. Closing issue!

paulocs’s picture

Status: Active » Fixed
paulocs’s picture

Status: Fixed » Closed (fixed)