diff --git a/context.core.inc b/context.core.inc
index 2d44c75..27beefa 100644
--- a/context.core.inc
+++ b/context.core.inc
@@ -318,6 +318,9 @@ function context_context_page_condition() {
if ($plugin = context_get_plugin('condition', 'sitewide')) {
$plugin->execute(1);
}
+ if ($plugin = context_get_plugin('condition', 'default')) {
+ $plugin->execute(1);
+ }
if ($plugin = context_get_plugin('condition', 'context')) {
$plugin->execute();
}
diff --git a/context.plugins.inc b/context.plugins.inc
index 6f86559..2ccb968 100644
--- a/context.plugins.inc
+++ b/context.plugins.inc
@@ -21,6 +21,11 @@ function _context_context_registry() {
'description' => t('Should this context always be set? If true, this context will be active across your entire site.'),
'plugin' => 'context_condition_sitewide',
),
+ 'default' => array(
+ 'title' => t('Default context'),
+ 'description' => t('This context will be set if no other context is active except sitewide contexts.'),
+ 'plugin' => 'context_condition_default',
+ ),
'path' => array(
'title' => t('Path'),
'description' => t('Set this context when any of the paths above match the page path. Put each path on a separate line. You can use the *
character (asterisk) as a wildcard and the ~
character (tilde) to exclude one or more paths. Use <front> for the site front page.'),
@@ -171,6 +176,14 @@ function _context_context_plugins() {
'parent' => 'context_condition',
),
);
+ $plugins['context_condition_default'] = array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'context') . '/plugins',
+ 'file' => 'context_condition_default.inc',
+ 'class' => 'context_condition_default',
+ 'parent' => 'context_condition',
+ ),
+ );
$plugins['context_condition_path'] = array(
'handler' => array(
'path' => drupal_get_path('module', 'context') . '/plugins',
diff --git a/plugins/context_condition_default.inc b/plugins/context_condition_default.inc
new file mode 100644
index 0000000..75de1fb
--- /dev/null
+++ b/plugins/context_condition_default.inc
@@ -0,0 +1,36 @@
+ t('Default context'));
+ }
+
+ function editor_form($context = NULL) {
+ $form = parent::editor_form($context);
+ $form[1]['#title'] = t('Default context');
+ $form['#weight'] = -10;
+ return $form;
+ }
+
+ function execute() {
+ if ($this->condition_used()) {
+ $active_contexts = context_active_contexts();
+
+ foreach ($active_contexts as $name => $context) {
+ foreach (array_keys($context->conditions) as $cond) {
+ if (!in_array($cond, array('default', 'sitewide'))) {
+ return;
+ }
+ }
+ }
+ foreach ($this->get_contexts('context_condition_default') as $context) {
+ $this->condition_met($context, 'context_condition_default');
+ }
+ }
+ }
+}
+