redirect node to term alpha
Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
parent
35a5eb3a60
commit
c952bd330f
42
tode.module
42
tode.module
@ -120,6 +120,12 @@ function tode_field_widget_settings_form($field, $instance){
|
|||||||
'#title' => t('Rewrite all term link to theire tode node ?'),
|
'#title' => t('Rewrite all term link to theire tode node ?'),
|
||||||
'#default_value' => $settings['redirect_term_to_node'],
|
'#default_value' => $settings['redirect_term_to_node'],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$form['redirect_node_to_term'] = array(
|
||||||
|
'#type' => 'checkbox',
|
||||||
|
'#title' => t('Rewrite all node link to theire term node ?'),
|
||||||
|
'#default_value' => $settings['redirect_node_to_term'],
|
||||||
|
);
|
||||||
|
|
||||||
$form['show_create_tode'] = array(
|
$form['show_create_tode'] = array(
|
||||||
'#type' => 'checkbox',
|
'#type' => 'checkbox',
|
||||||
@ -139,6 +145,8 @@ function _tode_widget_settings_maxlength_validate($element, &$form_state) {
|
|||||||
if (!is_numeric($value) || intval($value) != $value || $value <= 0) {
|
if (!is_numeric($value) || intval($value) != $value || $value <= 0) {
|
||||||
form_error($element, t('"Maximum length" must be a positive integer.'));
|
form_error($element, t('"Maximum length" must be a positive integer.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# TODO checke that node to term and term to node can't be chexked together
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -977,6 +985,7 @@ function tode_url_outbound_alter(&$path, &$options, $original_path) {
|
|||||||
// dsm('tode_url_outbound_alter');
|
// dsm('tode_url_outbound_alter');
|
||||||
# terms url
|
# terms url
|
||||||
$term = false;
|
$term = false;
|
||||||
|
$node = false;
|
||||||
// if(isset($options['entity_type']) && $options['entity_type'] == 'taxonomy_term'){
|
// if(isset($options['entity_type']) && $options['entity_type'] == 'taxonomy_term'){
|
||||||
// // dsm('- - - - tode_url_outbound_alter');
|
// // dsm('- - - - tode_url_outbound_alter');
|
||||||
// // dsm($path, '$path');
|
// // dsm($path, '$path');
|
||||||
@ -993,11 +1002,40 @@ function tode_url_outbound_alter(&$path, &$options, $original_path) {
|
|||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
# WARNING works only because nodeandtermrelink_url_outbound_alter() is trigered before this
|
|
||||||
|
if (preg_match('/^node\/([0-9]*)$/', $path, $matches)) {
|
||||||
|
$node = node_load($matches[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
# WARNING works only because nodeandtermrelink_url_outbound_alter() is trigered before this (KADIST)
|
||||||
if (preg_match('/^taxonomy\/term\/([0-9]*)$/', $path, $matches)) {
|
if (preg_match('/^taxonomy\/term\/([0-9]*)$/', $path, $matches)) {
|
||||||
$term = taxonomy_term_load($matches[1]);
|
$term = taxonomy_term_load($matches[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if($node){
|
||||||
|
// dsm($node, 'node');
|
||||||
|
if($fields = _tode_get_node_tode_fields_def($node)){
|
||||||
|
foreach ($fields as $field_name => $field) {
|
||||||
|
if (isset($field['widget']['settings']['redirect_node_to_term']) && $field['widget']['settings']['redirect_node_to_term']) {
|
||||||
|
dsm($field, '$field');
|
||||||
|
$items = field_get_items('node', $node, $field_name);
|
||||||
|
dsm($items, 'items');
|
||||||
|
$new_path = 'taxonomy/term/'.$items[0]['tid'];
|
||||||
|
if( $new_alias = drupal_get_path_alias($new_path) ){//, $options['language']->language
|
||||||
|
$path = $new_alias;
|
||||||
|
$original_path = $new_path;
|
||||||
|
$options['alias'] = TRUE;
|
||||||
|
}else{
|
||||||
|
$path = $new_path;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($term){
|
if($term){
|
||||||
// dsm($term, '$term : '.$term->name);
|
// dsm($term, '$term : '.$term->name);
|
||||||
if($field = _tode_get_voc_tode_field_def($term->vocabulary_machine_name)){
|
if($field = _tode_get_voc_tode_field_def($term->vocabulary_machine_name)){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user