You are here

function _display_faq_by_category in Frequently Asked Questions 5

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

File

./faq.module, line 736

Code

function _display_faq_by_category($faq_display, $category_display, $term, $display_header, &$output, &$output_answers) {
  $result = db_query(db_rewrite_sql("SELECT n.nid, n.title, r.body, r.teaser, r.format, if((w.weight IS NULL), 0, w.weight) as weight FROM {node} n LEFT JOIN {node_revisions} r ON n.nid = r.nid AND r.vid = n.vid INNER JOIN {term_node} tn ON n.nid = tn.nid LEFT JOIN {faq_weights} w ON w.tid = tn.tid AND n.nid = w.nid WHERE n.type='faq' AND n.status = 1 AND tn.tid = '%d' ORDER BY weight, n.sticky DESC, n.created DESC", "n", "nid"), $term->tid);
  $display_vars['display_header'] = $display_header;
  $display_vars['faq_display'] = $faq_display;
  $display_vars['category_display'] = $category_display;
  $display_vars['faq_qa_mark'] = variable_get('faq_qa_mark', FALSE);
  $display_vars['faq_question_label'] = variable_get('faq_question_label', "Q:");
  $display_vars['faq_answer_label'] = variable_get('faq_answer_label', "A:");
  $display_vars['use_teaser'] = variable_get('faq_use_teaser', FALSE);
  $display_vars['more_link'] = variable_get('faq_more_link', '>> more');
  $display_vars['back_to_top'] = variable_get('faq_back_to_top', 'Back to Top');
  $display_vars['faq_count'] = variable_get('faq_count', FALSE);
  $display_vars['group_questions_top'] = variable_get('faq_group_questions_top', FALSE);
  $display_vars['hide_sub_categories'] = variable_get('faq_hide_sub_categories', FALSE);
  $display_vars['show_cat_sub_cats'] = variable_get('faq_show_cat_sub_cats', FALSE);

  // handle indenting of categories
  $depth = 0;
  while ($depth < $term->depth) {
    $display_vars['display_header'] = 1;
    $indent = '<div class="faq_category_indent">';
    $output .= $indent;
    $depth++;
  }

  // set up the class name for hiding the q/a for a category if required
  $faq_class = "faq_qa";
  if ($category_display == "hide_qa") {
    $faq_class = "faq_qa_hide";
  }
  switch ($faq_display) {
    case 'questions_top':
      $data = theme('category_questions_top', $result, $display_vars, $term, $faq_class);
      $output .= $data["output"];
      $output_answers .= $data["output_answers"];
      break;
    case 'hide_answer':
      $output .= theme('category_hide_answer', $result, $display_vars, $term, $faq_class);
      break;
    case 'questions_inline':
      $output .= theme('category_questions_inline', $result, $display_vars, $term, $faq_class);
      break;
    case 'new_page':
      $output .= theme('category_new_page', $result, $display_vars, $term, $faq_class);
      break;
  }

  // end of switch (faq_display)
  // handle indenting of categories
  while ($depth > 0) {
    $output .= '</div>';
    $depth--;
  }
}