Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save orakili/1264544 to your computer and use it in GitHub Desktop.
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.
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