function _display_faq_by_category in Frequently Asked Questions 6
Same name and namespace in other branches
- 5.2 faq.module \_display_faq_by_category()
- 5 faq.module \_display_faq_by_category()
- 7.2 faq.module \_display_faq_by_category()
- 7 faq.module \_display_faq_by_category()
Display FAQ questions and answers filtered by category.
Parameters
$faq_display: Define the way the FAQ is being shown; can have the values: 'questions top',hide answers','questions inline','new page'.
$category_display: The layout of categories which should be used.
$term: The category / term to display FAQs for.
$display_header: Set if the header will be shown or not.
&$output: Reference which holds the content of the page, HTML formatted.
&$output_answer: Reference which holds the answers from the FAQ, when showing questions on top.
1 call to _display_faq_by_category()
- faq_page in ./
faq.module - Function to display the faq page.
File
- ./
faq.module, line 582 - The FAQ module allows users to create a FAQ page, with questions and answers displayed in different styles, according to the settings.
Code
function _display_faq_by_category($faq_display, $category_display, $term, $display_header, &$output, &$output_answers) {
$default_sorting = variable_get('faq_default_sorting', 'DESC');
$default_weight = 0;
if ($default_sorting != 'DESC') {
$default_weight = 1000000;
$result = db_query(db_rewrite_sql("SELECT n.nid, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) 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 effective_weight, n.sticky DESC, n.created ASC", "n", "nid"), $default_weight, $term->tid);
}
else {
$result = db_query(db_rewrite_sql("SELECT n.nid, COALESCE(w.weight, %d) as effective_weight, n.sticky, n.created FROM {node} n INNER JOIN {term_node} tn ON (n.nid = tn.nid AND n.vid = tn.vid) 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 effective_weight, n.sticky DESC, n.created DESC", "n", "nid"), $default_weight, $term->tid);
}
$data = array();
while ($row = db_fetch_object($result)) {
$node = node_load($row->nid);
if (node_access('view', $node)) {
$data[] = $node;
}
}
// Handle indenting of categories.
$depth = 0;
if (!isset($term->depth)) {
$term->depth = 0;
}
while ($depth < $term->depth) {
$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";
}
$faq_path = drupal_get_path('module', 'faq') . '/includes';
switch ($faq_display) {
case 'questions_top':
include_once $faq_path . '/faq.questions_top.inc';
// @todo fix workaround: have to share result.
$output .= theme('faq_category_questions_top', $data, $display_header, $category_display, $term, $faq_class, $term);
$output_answers .= theme('faq_category_questions_top_answers', $data, $display_header, $category_display, $term, $faq_class, $term);
break;
case 'hide_answer':
include_once $faq_path . '/faq.hide_answer.inc';
$output .= theme('faq_category_hide_answer', $data, $display_header, $category_display, $term, $faq_class, $term);
break;
case 'questions_inline':
include_once $faq_path . '/faq.questions_inline.inc';
$output .= theme('faq_category_questions_inline', $data, $display_header, $category_display, $term, $faq_class, $term);
break;
case 'new_page':
include_once $faq_path . '/faq.new_page.inc';
$output .= theme('faq_category_new_page', $data, $display_header, $category_display, $term, $faq_class, $term);
break;
}
// End of switch (faq_display).
// Handle indenting of categories.
while ($depth > 0) {
$output .= '</div>';
$depth--;
}
}