diff --git sites/all/modules/contrib/views/modules/taxonomy.views.inc sites/all/modules/contrib/views/modules/taxonomy.views.inc index ff1cb6b..e20e142 100644 --- sites/all/modules/contrib/views/modules/taxonomy.views.inc +++ sites/all/modules/contrib/views/modules/taxonomy.views.inc @@ -464,6 +464,12 @@ function taxonomy_views_plugins() { 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', 'parent' => 'fixed', ), + 'taxonomy_tid_node' => array( + 'title' => t('Taxonomy Term ID from current node'), + 'handler' => 'views_plugin_argument_default_taxonomy_tid_node', + 'path' => drupal_get_path('module', 'views') . '/modules/taxonomy', + 'parent' => 'taxonomy_tid', + ), ), ); } diff --git sites/all/modules/contrib/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid_node.inc sites/all/modules/contrib/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid_node.inc new file mode 100644 index 0000000..70dcf16 --- /dev/null +++ sites/all/modules/contrib/views/modules/taxonomy/views_plugin_argument_default_taxonomy_tid_node.inc @@ -0,0 +1,72 @@ +option_name] = array( + '#type' => 'select', + '#title' => t('How to combine term IDs'), + '#description' => t("Whether to form multiple term IDs into the argument with '+' or ','."), + '#options' => array( + 'and' => 'and', + 'or' => 'or', + ), + '#default_value' => $this->argument->options[$this->option_name], + '#process' => array('views_process_dependency'), + '#dependency' => array( + 'radio:options[default_action]' => array('default'), + 'radio:options[default_argument_type]' => array($this->id) + ), + '#dependency_count' => 2, + ); + } + + /** + * Get an argument from the current node's taxonomy terms. + */ + function get_argument() { + // First, try to get a node from the menu router system. + $node = menu_get_object('node', 1); + if (!empty($node)) { + // If our argument is set to validate the term, only pick out + // terms from the node that are in those vocabularies. + if ($this->argument->options['validate_type'] == 'taxonomy_term') { + $valid_vids = $this->argument->options['validate_argument_vocabulary']; + foreach ($node->taxonomy as $tid => $term) { + // This has VID => VID for selected ones, and VID => 0 otherwise. + if ($valid_vids[$term->vid]) { + $tids[] = $tid; + } + } + } + // Otherwise, take all terms from the node. + else { + $tids = array_keys($node->taxonomy); + } + + if ($tids) { + // Transform the argument to a string of tids, in the form + // of 1+2+3 (for OR) or 1,2,3 (for AND). + if ($this->argument->options[$this->option_name] == 'and') { + $glue = ','; + } + else { + $glue = '+'; + } + + $argument_value = implode($glue, $tids); + return $argument_value; + } + } + // Views will just do nothing for this argument if we end up here. + } +}