function _get_indented_faq_terms in Frequently Asked Questions 6
Same name and namespace in other branches
- 5.2 faq.module \_get_indented_faq_terms()
- 5 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 916 - 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')) {
module_load_include('inc', 'pathauto');
}
$display_faq_count = variable_get('faq_count', FALSE);
$hide_child_terms = variable_get('faq_hide_child_terms', FALSE);
$items = array();
$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 = '';
if (!empty($term->description)) {
$desc = '<div class="faq-qa-description">';
$desc .= check_markup(faq_tt("taxonomy:term:{$term->tid}:description", $term->description)) . "</div>";
}
// 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 AND n.vid = tn.vid) 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 ($display_faq_count) {
$count = $term_node_count->c;
if ($hide_child_terms) {
$count = $tree_count;
}
$cur_item = $term_image . l(faq_tt("taxonomy:term:{$term->tid}:name", $term->name), $path) . " ({$count}) " . $desc;
}
else {
$cur_item = $term_image . l(faq_tt("taxonomy:term:{$term->tid}:name", $term->name), $path) . $desc;
}
}
else {
$cur_item = $term_image . check_plain(faq_tt("taxonomy:term:{$term->tid}:name", $term->name)) . $desc;
}
if (!empty($term_image)) {
$cur_item .= '<div class="clear-block"></div>';
}
$term_items = array();
if (!$hide_child_terms) {
$term_items = _get_indented_faq_terms($vid, $term->tid);
}
$items[] = array(
"data" => $cur_item,
"children" => $term_items,
);
}
}
return $items;
}