function _get_indented_faq_terms in Frequently Asked Questions 5.2
Same name and namespace in other branches
- 5 faq.module \_get_indented_faq_terms()
- 6 faq.module \_get_indented_faq_terms()
- 7.2 faq.module \_get_indented_faq_terms()
- 7 faq.module \_get_indented_faq_terms()
Return a HTML formatted list of terms indented according to the term depth.
Parameters
$vid: Vocabulary id.
$tid: Term id.
Return value
Return a HTML formatted list of terms indented according to the term depth.
2 calls to _get_indented_faq_terms()
- faq_get_terms in ./
faq.module - Get a list of terms associated with the FAQ nodes.
- faq_page in ./
faq.module - Function to display the faq page.
File
- ./
faq.module, line 1275 - The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.
Code
function _get_indented_faq_terms($vid, $tid) {
if (module_exists('pathauto')) {
_pathauto_include();
}
$items = array();
$faq_count = variable_get('faq_count', FALSE);
$hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
$tree = taxonomy_get_tree($vid, $tid, -1, 1);
foreach ($tree as $term) {
$tree_count = taxonomy_term_count_nodes($term->tid, 'faq');
if ($tree_count) {
// Get taxonomy image.
$term_image = '';
if (module_exists('taxonomy_image')) {
$term_image = taxonomy_image_display($term->tid, array(
'class' => 'faq-tax-image',
));
}
// Get term description.
$desc = theme('faq_category_description', check_markup($term->description));
// See if this term has any nodes itself, should it be a link?
$result = db_query(db_rewrite_sql("SELECT COUNT(n.nid) AS c FROM {term_node} tn INNER JOIN {node} n ON n.nid = tn.nid WHERE n.status = 1 AND n.type = 'faq' AND tn.tid = '%d' ", "n", "nid"), $term->tid);
$term_node_count = db_fetch_object($result);
if ($term_node_count->c > 0) {
$path = "faq/{$term->tid}";
if (!drupal_lookup_path('alias', arg(0) . '/' . $term->tid) && module_exists('pathauto')) {
$placeholders = pathauto_get_placeholders('taxonomy', $term);
$path = pathauto_create_alias('faq', 'insert', $placeholders, arg(0) . '/' . $term->tid, $term->tid);
}
if ($faq_count) {
$node_count = $term_node_count->c;
if ($hide_child_terms) {
$node_count = $tree_count;
}
$cur_item = $term_image . l($term->name, $path) . " ({$node_count}) " . $desc;
}
else {
$cur_item = $term_image . l($term->name, $path) . $desc;
}
}
else {
$cur_item = $term_image . check_plain($term->name) . $desc;
}
if (!empty($term_image)) {
$cur_item .= '<div class="clear-block"></div>';
}
if (!$hide_child_terms) {
$term_items = _get_indented_faq_terms($vid, $term->tid);
}
$items[] = array(
"data" => $cur_item,
"children" => $term_items,
);
}
}
return $items;
}