Deleting contexts in Drupal 7
Blog
Written with a loving hand by kitt some time around 13:24 on 19 November 2013
When removing contexts, use context_load
to retrieve context object from the database, then context_delete
to remove it.
A specific example:
function example_update_7001() { // 'example_one' is the value at /admin/structure/context in the Name column $contexts = array('example_one', 'example_two'); foreach ($contexts as $context_name) { // load the context from the DB $context = context_load($context_name); // context_load returns FALSE if the context doesn't exist if ($context) { context_delete($context); } } }
You can also check the module is even enabled with module_exists('context')
around those lines.
Add new comment