You are here

function _get_indented_faq_terms in Frequently Asked Questions 5

Same name and namespace in other branches
  1. 5.2 faq.module \_get_indented_faq_terms()
  2. 6 faq.module \_get_indented_faq_terms()
  3. 7.2 faq.module \_get_indented_faq_terms()
  4. 7 faq.module \_get_indented_faq_terms()
2 calls to _get_indented_faq_terms()
faq_get_terms in ./faq.module
faq_page in ./faq.module
Function to display the faq page

File

./faq.module, line 1730

Code

function _get_indented_faq_terms($vid, $tid, $display_vars) {
  $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 term description
      $desc = '';
      if (!empty($term->description)) {
        $desc = '<div class="faq_qa_description"><p>';
        $desc .= $term->description . "</p></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} t INNER JOIN {node} n ON t.nid = n.nid WHERE n.status = 1 AND n.type = 'faq' AND t.tid = '%d' ", "n", "nid"), $term->tid);
      $term_count = db_fetch_object($result);
      if ($term_count->c > 0) {
        if ($display_vars["faq_count"]) {
          $count = $term_count->c;
          if ($display_vars['hide_sub_categories']) {
            $count = $tree_count;
          }
          $cur_item = l($term->name, "faq/{$term->tid}") . " ({$count}) " . $desc;
        }
        else {
          $cur_item = l($term->name, "faq/{$term->tid}") . $desc;
        }
      }
      else {
        $cur_item = check_plain($term->name) . $desc;
      }
      if (!$display_vars['hide_sub_categories']) {
        $term_items = _get_indented_faq_terms($vid, $term->tid, $display_vars);
      }
      $items[] = array(
        "data" => $cur_item,
        "children" => $term_items,
      );
    }
  }
  return $items;
}