function theme_category_new_page in Frequently Asked Questions 5
1 theme call to theme_category_new_page()
File
- ./
faq.module, line 1475
Code
function theme_category_new_page($result, $display_vars, $term, $class) {
$get_sub_terms = 0;
if (arg(0) == 'faq' && is_numeric(arg(1))) {
$get_sub_terms = arg(1);
}
// get number of questions, and account for hidden sub-cats
if ($display_vars['faq_count']) {
$count = db_num_rows($result);
if ($display_vars['hide_sub_categories']) {
$count = taxonomy_term_count_nodes($term->tid, 'faq');
}
}
// configure header
$hdr = "h5";
if ($term->depth > 0) {
$hdr = "h6";
}
if ($display_vars['category_display'] == 'hide_qa') {
$header = "<{$hdr} class=\"faq_header\">";
$header .= l($term->name, "faq/{$term->tid}");
if ($display_vars['faq_count']) {
$header .= " (%d)";
}
$header .= "</{$hdr}>\n";
}
else {
$header = "<{$hdr} class=\"faq_header\">";
$header .= check_plain($term->name);
if ($display_vars['faq_count']) {
$header .= " (%d)";
}
$header .= "</{$hdr}>\n";
}
$desc = '';
if (!empty($term->description)) {
$desc = '<div class="faq_qa_description"><p>';
$desc .= $term->description . "</p></div>\n";
}
// get list of sub-categories if necessary
$sub_cats = '';
if (($display_vars['show_cat_sub_cats'] || $display_vars['hide_sub_categories']) && $display_vars['category_display'] == 'new_page') {
$list = taxonomy_get_children($term->tid);
$scats = array();
foreach ($list as $tid => $sub_term) {
$sub_count = taxonomy_term_count_nodes($sub_term->tid, 'faq');
if ($sub_count) {
$sub_cat_desc = '';
if (!empty($sub_term->description)) {
$sub_cat_desc = '<div class="faq_qa_description"><p>';
$sub_cat_desc .= $sub_term->description . "</p></div>";
}
if ($display_vars['faq_count']) {
$scats[] = l($sub_term->name, "faq/{$sub_term->tid}") . " ({$sub_count}) {$sub_cat_desc}";
}
else {
$scats[] = l($sub_term->name, "faq/{$sub_term->tid}") . $sub_cat_desc;
}
}
}
$list_style = variable_get('faq_category_listing', 'ul');
$sub_cats .= theme('item_list', $scats, NULL, $list_style, array(
"class" => "faq_category_list",
));
}
$output = '<div class="faq_category_group">' . "\n";
if ($display_vars['display_header'] == 1) {
$output .= '<div class="faq_qa_header">' . $header . $desc . "</div>\n";
}
else {
$output .= '<div class="faq_qa_header">' . $desc . "</div>\n";
}
$output .= $sub_cats;
$sub_cats = '';
if ($get_sub_terms == $term->tid) {
$output .= '<div class="faq_qa">' . "\n";
}
else {
$output .= '<div class="' . $class . '">' . "\n";
}
if ($get_sub_terms && $display_vars['category_display'] == 'categories_inline' || ($display_vars['show_cat_sub_cats'] || $display_vars['hide_sub_categories']) && $display_vars['category_display'] == 'hide_qa') {
$list = taxonomy_get_children($term->tid);
foreach ($list as $tid => $sub_term) {
if (taxonomy_term_count_nodes($sub_term->tid, 'faq')) {
$sub_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"), $sub_term->tid);
$display_vars['display_header'] = 1;
$sub_cats .= '<div class="faq_category_indent">';
$sub_cats .= theme('category_new_page', $sub_result, $display_vars, $sub_term, $class);
$sub_cats .= '</div>';
}
}
$output .= $sub_cats;
}
if (db_num_rows($result)) {
$items = array();
while ($node = db_fetch_object($result)) {
$node = node_load($node->nid);
if (node_access("view", $node)) {
$items[] = l($node->title, "node/{$node->nid}");
}
else {
$count--;
}
}
$list_style = variable_get('faq_question_listing', 'ul');
$output .= theme('item_list', $items, NULL, $list_style, array(
"class" => "faq_ul_new_page",
));
}
$output .= "</div>\n</div>\n";
if ($display_vars['faq_count']) {
$output = sprintf($output, $count);
}
return $output;
}