--- taxonomy_context.module.orig 2008-06-05 02:25:06.000000000 +0200 +++ taxonomy_context.module 2008-06-05 02:23:04.000000000 +0200 @@ -121,9 +121,7 @@ function taxonomy_context_block($op = 'l $vocabularies = taxonomy_get_vocabularies(); foreach ($vocabularies as $vid => $vocabulary) { - if ($vocabulary->module == 'taxonomy' || !module_hook($vocabulary->module, 'term_path')) { - $blocks[$vid]['info'] = t('Context for !vocabulary', array('!vocabulary' => check_plain($vocabulary->name))); - } + $blocks[$vid]['info'] = t('Context for !vocabulary', array('!vocabulary' => check_plain($vocabulary->name))); } return $blocks; @@ -308,6 +306,33 @@ function taxonomy_context_get_context() } break; default: + if(variable_get('taxonomy_context_term_path_filters', false)){ + $term_path_filter_tid_match = 0; + $term_path_filters = split("\n", variable_get('taxonomy_context_term_path_filters', false)); + foreach($term_path_filters AS $term_path_filter){ + $term_path_filter = rtrim($term_path_filter); + $term_path_filter_args = split('/', $term_path_filter); + foreach($term_path_filter_args AS $filter_key => $filter_value){ + if($filter_value == 'ID' && is_numeric(arg($filter_key))){ + $term_path_filter_tid_match = arg($filter_key); + } + elseif(!preg_match("/^$filter_value$/", arg($filter_key))){ + $term_path_filter_tid_match = 0; + break; + } + } + if($term_path_filter_tid_match){ + $context['tid'] = $term_path_filter_tid_match; + list($top_parent) = taxonomy_get_parents_all($context['tid']); + $context['root_tid'] = $top_parent->tid; + $term = taxonomy_get_term($context['tid']); + $context['vid'] = $term->vid; + break; + } + } + } break; } $context = (object) $context; @@ -615,6 +640,14 @@ function taxonomy_context_admin_settings '#options' => array(t('Collapsed'), t('Expanded')), '#description' => t('Do you want items on the menu expanded or collapsed by default?'), ); + $form['general_settings']['taxonomy_context_term_path_filters'] = array( + '#type' => 'textarea', + '#title' => t('Term path filters'), + '#default_value' => variable_get('taxonomy_context_term_path_filters', ''), + '#description' => t('If youre use some modules like taxonomy_redirect, that changes the destination of Taxonomy Term links, you need to add filters that matching the URL format. Call that Arg, wich contains the Taxonomy Id: ID. You may use PCRE for each arg. One line per Filter. Do not place a leading or trailing /. Examples: +
news/.+/ID Paths like: news/term name/term id +
news/ID/.+ Paths like: news/term id/term name'), + ); return system_settings_form($form); }