Created
October 5, 2011 14:21
-
-
Save orakili/1264544 to your computer and use it in GitHub Desktop.
Drupal - Context 7.x-3.x - Handles specific entity paths with additional path elements.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git context.core.inc context.core.inc | |
index 5a85e8a..398356f 100644 | |
--- context.core.inc | |
+++ context.core.inc | |
@@ -209,22 +209,21 @@ function context_views_pre_view($view, $display) { | |
} | |
// Support Views overrides of specific entity paths. | |
if ($view->display_handler->has_path()) { | |
- switch ($view->display_handler->get_option('path')) { | |
- case 'taxonomy/term/%': | |
- if (($term = taxonomy_term_load(arg(2))) && ($plugin = context_get_plugin('condition', 'taxonomy_term'))) { | |
- $plugin->execute($term, 'view'); | |
- } | |
- break; | |
- case 'node/%': | |
- if ($node = node_load(arg(1))) { | |
- context_node_condition($node, 'view'); | |
- } | |
- break; | |
- case 'user/%': | |
- if (($account = user_load(arg(1))) && ($plugin = context_get_plugin('condition', 'user_page'))) { | |
- $plugin->execute($account, 'view'); | |
- } | |
- break; | |
+ $path = $view->display_handler->get_option('path'); | |
+ if (strpos($path, 'taxonomy/term/%') === 0) { | |
+ if (($term = taxonomy_term_load(arg(2))) && ($plugin = context_get_plugin('condition', 'taxonomy_term'))) { | |
+ $plugin->execute($term, 'view'); | |
+ } | |
+ } | |
+ elseif (strpos($path, 'node/%') === 0) { | |
+ if ($node = node_load(arg(1))) { | |
+ context_node_condition($node, 'view'); | |
+ } | |
+ } | |
+ elseif (strpos($path, 'user/%') === 0) { | |
+ if (($account = user_load(arg(1))) && ($plugin = context_get_plugin('condition', 'user_page'))) { | |
+ $plugin->execute($account, 'view'); | |
+ } | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment