function faq_link_alter in Frequently Asked Questions 5.2
Same name and namespace in other branches
- 6 faq.module \faq_link_alter()
Implementation of hook_link_alter().
Change the term links on a node to point at the appropriate faq page.
File
- ./
faq.module, line 1419 - The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.
Code
function faq_link_alter(&$node, &$links) {
static $vocabularies;
if ($node->type != 'faq' || !variable_get('faq_use_categories', FALSE) || !module_exists("taxonomy") || !variable_get('faq_enable_term_links', 1)) {
return;
}
if (!isset($vocabularies)) {
$vocabularies = taxonomy_get_vocabularies('faq');
$vocab_omit = array_flip(variable_get('faq_omit_vocabulary', array()));
$vocabularies = array_diff_key($vocabularies, $vocab_omit);
}
foreach ($links as $module => $link) {
if (strpos($module, 'taxonomy_term') !== FALSE) {
// Link back to the faq and not the taxonomy term page. We'll only
// do this if the taxonomy term in question belongs to faq vocab.
$tid = str_replace('taxonomy/term/', '', $link['href']);
$term = taxonomy_get_term($tid);
foreach ($vocabularies as $vid => $vobj) {
if ($term->vid == $vid && taxonomy_term_count_nodes($term->tid, 'faq')) {
$links[$module]['href'] = str_replace('taxonomy/term', 'faq', $link['href']);
break;
}
}
}
}
}