function taxonomy_redirect_term_path in Taxonomy Redirect 5
Same name and namespace in other branches
- 6 taxonomy_redirect.module \taxonomy_redirect_term_path()
Implementation of hook_term_path() from the taxonomy module.
File
- ./
taxonomy_redirect.module, line 489
Code
function taxonomy_redirect_term_path($term) {
// Get term data in case the term passed in is incomplete.
// Don't overwrite if the data is there though
$t = taxonomy_get_term($term->tid);
$term->name = isset($term->name) ? $term->name : $t->name;
$term->description = isset($term->descrition) ? $term->description : $t->description;
$term->weight = isset($term->weight) ? $term->weight : $t->weight;
$redirect = db_fetch_object(db_query("SELECT path, separator_replace, remove_text, filter\n FROM {taxonomy_redirect} \n WHERE vid = '%d' \n AND tid = '%d'", $term->vid, $term->tid));
if (!$redirect || !$redirect->path) {
$redirect = db_fetch_object(db_query("SELECT path, separator_replace, remove_text, filter\n FROM {taxonomy_redirect} \n WHERE vid = '%d' \n AND tid IS NULL", $term->vid));
}
if (!$redirect || !$redirect->path) {
return 'taxonomy/term/' . $term->tid;
}
// If php code then add the term variables so the code can use them.
if (substr($redirect->path, 0, 2) == '<?') {
// Get the nid of the node that this link is being printed for
$nid = taxonomy_redirect_get_php_nid_variable();
$text = '<?php ';
$text .= '$tid = ' . $term->tid . '; ';
$text .= '$tname = ' . "'" . $term->name . "'; ";
$text .= '$nid = ' . $nid . '; ';
$openingtag = strpos(strtolower($redirect->path), 'php') + 3;
$text .= substr($redirect->path, $openingtag);
}
else {
$text = $redirect->path;
}
$path = trim(_taxonomy_redirect_exec_filter($text, $redirect->filter));
$separator = $redirect->separator_replace;
$remove_text = $redirect->remove_text;
$path_case = $redirect->path_case;
if (function_exists('taxonomy_redirect_custom_term_path')) {
return taxonomy_redirect_custom_term_path($term, $path, $separator, $remove_text, $path_case);
}
return taxonomy_redirect_default_term_path($term, $path, $separator, $remove_text, $path_case);
}