1. In context.plugins.inc un-comment lines for "context_condition_node_taxonomy.inc" plugin.
2. Source of context_condition_node_taxonomy.inc. It's harcoded for term reference field "field_product_type".
/**
* Expose node taxonomy terms as a context condition.
*/
class context_condition_node_taxonomy extends context_condition_node {
function condition_values() {
$values = array();
if (module_exists('taxonomy')) {
foreach (taxonomy_get_vocabularies() as $vocab) {
if (empty($vocab->tags)) {
foreach (taxonomy_get_tree($vocab->vid) as $term) {
$values[$term->tid] = check_plain($term->name);
}
}
}
}
return $values;
}
function condition_form($context) {
$form = parent::condition_form($context);
$form['#type'] = 'select';
$form['#size'] = 12;
$form['#multiple'] = TRUE;
$form['#values'] = taxonomy_get_vocabularies(); //taxonomy_form_all();
return $form;
}
function execute($node, $op) {
if ($this->condition_used() && !empty($node->field_product_type)) {
foreach ($node->field_product_type[$node->language] as $term) {
foreach ($this->get_contexts($term['tid']) as $context) {
// Check the node form option.
if ($op === 'form') {
$options = $this->fetch_from_context($context, 'options');
if (!empty($options['node_form'])) {
$this->condition_met($context, $term['tid']);
}
}
else {
$this->condition_met($context, $term['tid']);
}
}
}
}
}
}
Will try to make more usable UI and to remove harcoded tearm reference.
Comments
Comment #1
fjcalzado@gmail.com commentedWould be nice a more user-friendly implementation of this feature.
Thanks for your work
Comment #2
markovucinicbg commentedGreat idea!
Comment #3
tekante commentedAttached is a patch that should check any taxonomy term reference field attached to a node. Also, I was receiving an error when attempting to use taxonomy_get_vocabularies() in the condition form so I implemented the term selection form used in the 6.x-3 version.
Comment #4
tekante commentedComment #5
febbraro commentedInitial patch committed. http://drupal.org/cvs?commit=502712
Still needs a reworked unit test.
Comment #6
febbraro commentedThe test is now in CVS. It is not passing, but how it creates nodes/taxonomy etc are all in place. The condition seems to work when testing on a real site, but the test is not working.
Comment #7
dstolsub
Comment #8
febbraro commentedTaxonomy Node Test is fixed.
Comment #9
Yuri commenteddisregard this comment - i confirm it works in latest version