Index: faq.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faq/faq.module,v retrieving revision 1.1.4.52.2.92 diff -u -p -r1.1.4.52.2.92 faq.module --- faq.module 22 Dec 2008 01:34:51 -0000 1.1.4.52.2.92 +++ faq.module 30 Dec 2008 17:05:10 -0000 @@ -315,11 +315,15 @@ function faq_view($node, $teaser = FALSE * @param $tid * Default is 0, determines if the questions and answers on the page * will be shown according to a category or non-categorized. + * @param $faq_display + * Optional parameter to override default question layout setting. + * @param $category_display + * Optional parameter to override default category layout setting. * @return * The output variable which contains an HTML formatted page with FAQ * questions and answers. */ -function faq_page($tid = 0) { +function faq_page($tid = 0, $faq_display = '', $category_display = '') { if (module_exists('pathauto')) { _pathauto_include(); } @@ -336,7 +340,7 @@ function faq_page($tid = 0) { $tid = 0; } - // configure the breadcrumb trail. + // Configure the breadcrumb trail. if (!empty($tid) && $current_term = taxonomy_get_term($tid)) { if (!drupal_lookup_path('alias', arg(0) .'/'. arg(1)) && module_exists('pathauto')) { $placeholders = pathauto_get_placeholders('taxonomy', taxonomy_get_term($tid)); @@ -348,9 +352,16 @@ function faq_page($tid = 0) { } - $faq_display = variable_get('faq_display', 'questions_top'); + if (empty($faq_display)) { + $faq_display = variable_get('faq_display', 'questions_top'); + } $use_categories = variable_get('faq_use_categories', FALSE); - if (!module_exists("taxonomy")) $use_categories = FALSE; + if (!empty($category_display)) { + $use_categories = TRUE; + } + if (!module_exists("taxonomy")) { + $use_categories = FALSE; + } $faq_path = drupal_get_path('module', 'faq') .'/includes'; @@ -400,7 +411,9 @@ function faq_page($tid = 0) { // Categorize questions. else { - $category_display = variable_get('faq_category_display', 'categories_inline'); + if (empty($category_display)) { + $category_display = variable_get('faq_category_display', 'categories_inline'); + } $hide_child_terms = variable_get('faq_hide_child_terms', FALSE); $output .= "
"; @@ -543,26 +556,26 @@ function _display_faq_by_category($faq_d 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); - $output_answers .= theme('faq_category_questions_top_answers', $data, $display_header, $category_display, $term, $faq_class); + $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); + $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); + $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); + $output .= theme('faq_category_new_page', $data, $display_header, $category_display, $term, $faq_class, $term); break; } // End of switch (faq_display). @@ -592,13 +605,13 @@ function faq_theme() { 'path' => $path, 'file' => 'faq.questions_top.inc', 'template' => 'faq-category-questions-top', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL), + 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), ), 'faq_category_questions_top_answers' => array( 'path' => $path, 'file' => 'faq.questions_top.inc', 'template' => 'faq-category-questions-top-answers', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL), + 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), ), 'faq_hide_answer' => array( 'path' => $path, @@ -610,7 +623,7 @@ function faq_theme() { 'path' => $path, 'file' => 'faq.hide_answer.inc', 'template' => 'faq-category-hide-answer', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL), + 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), ), 'faq_questions_inline' => array( 'path' => $path, @@ -622,7 +635,7 @@ function faq_theme() { 'path' => $path, 'file' => 'faq.questions_inline.inc', 'template' => 'faq-category-questions-inline', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL), + 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), ), 'faq_new_page' => array( 'path' => $path, @@ -634,7 +647,7 @@ function faq_theme() { 'path' => $path, 'file' => 'faq.new_page.inc', 'template' => 'faq-category-new-page', - 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL), + 'arguments' => array('data' => NULL, 'display_header' => 0, 'category_display' => NULL, 'term' => NULL, 'class' => NULL, 'parent_term' => NULL), ), ); } @@ -1146,8 +1159,10 @@ function faq_init_back_to_top($path) { * @param $class * CSS class which the HTML div will be using. A special class name is * required in order to hide and questions / answers. + * @param $parent_term + * The original, top-level, term we're displaying FAQs for. */ -function faq_get_child_categories_faqs($term, $theme_function, $default_weight, $default_sorting, $category_display, $class) { +function faq_get_child_categories_faqs($term, $theme_function, $default_weight, $default_sorting, $category_display, $class, $parent_term = NULL) { $output = array(); $list = taxonomy_get_children($term->tid); @@ -1170,7 +1185,7 @@ function faq_get_child_categories_faqs($ $data[] = $node; } } - $output[] = theme($theme_function, $data, 1, $category_display, $child_term, $class); + $output[] = theme($theme_function, $data, 1, $category_display, $child_term, $class, $parent_term); } } Index: includes/faq.hide_answer.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faq/includes/Attic/faq.hide_answer.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 faq.hide_answer.inc --- includes/faq.hide_answer.inc 21 Dec 2008 18:58:26 -0000 1.1.2.5 +++ includes/faq.hide_answer.inc 30 Dec 2008 17:05:10 -0000 @@ -46,6 +46,7 @@ function template_preprocess_faq_categor $data = $variables['data']; $category_display = $variables['category_display']; $term = $variables['term']; + $parent_term = $variables['parent_term']; $class = $variables['class']; // Fetch configuration. @@ -64,8 +65,18 @@ function template_preprocess_faq_categor } $this_page = $_GET['q']; $get_child_terms = 0; - if (arg(0) == 'faq' && is_numeric(arg(1))) { - $get_child_terms = arg(1); + // Check if we're on a faq page. + if (arg(0) == 'faq') { + // Check if we're on a categorized faq page. + if (is_numeric(arg(1))) { + $get_child_terms = arg(1); + } + } + // Force some settings in case we're processing a special faq question list + // created by a custom call to faq_page(). + elseif (!empty($parent_term)) { + $get_child_terms = $parent_term->tid; + $show_term_page_children = TRUE; } @@ -114,7 +125,7 @@ function template_preprocess_faq_categor // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) { - $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_hide_answer', $default_weight, $default_sorting, $category_display, $variables['class']); + $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_hide_answer', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } if (!count($data)) { Index: includes/faq.new_page.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faq/includes/Attic/faq.new_page.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 faq.new_page.inc --- includes/faq.new_page.inc 21 Dec 2008 18:58:26 -0000 1.1.2.5 +++ includes/faq.new_page.inc 30 Dec 2008 17:05:10 -0000 @@ -38,6 +38,7 @@ function template_preprocess_faq_categor $data = $variables['data']; $category_display = $variables['category_display']; $term = $variables['term']; + $parent_term = $variables['parent_term']; $class = $variables['class']; // Fetch configuration. @@ -47,9 +48,20 @@ function template_preprocess_faq_categor // Initialise some variables. $get_child_terms = 0; - if (arg(0) == 'faq' && is_numeric(arg(1))) { - $get_child_terms = arg(1); + // Check if we're on a faq page. + if (arg(0) == 'faq') { + // Check if we're on a categorized faq page. + if (is_numeric(arg(1))) { + $get_child_terms = arg(1); + } + } + // Force some settings in case we're processing a special faq question list + // created by a custom call to faq_page(). + elseif (!empty($parent_term)) { + $get_child_terms = $parent_term->tid; + $show_term_page_children = TRUE; } + $default_sorting = variable_get('faq_default_sorting', 'DESC'); $default_weight = 0; if ($default_sorting != 'DESC') { @@ -100,7 +112,7 @@ function template_preprocess_faq_categor // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) { - $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_new_page', $default_weight, $default_sorting, $category_display, $variables['class']); + $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_new_page', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } if (!count($data)) { Index: includes/faq.questions_inline.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faq/includes/Attic/faq.questions_inline.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 faq.questions_inline.inc --- includes/faq.questions_inline.inc 21 Dec 2008 18:58:26 -0000 1.1.2.5 +++ includes/faq.questions_inline.inc 30 Dec 2008 17:05:10 -0000 @@ -53,6 +53,7 @@ function template_preprocess_faq_categor $data = $variables['data']; $category_display = $variables['category_display']; $term = $variables['term']; + $parent_term = $variables['parent_term']; $class = $variables['class']; // Fetch configuration. @@ -71,10 +72,21 @@ function template_preprocess_faq_categor } $this_page = $_GET['q']; $get_child_terms = 0; - if (arg(0) == 'faq' && is_numeric(arg(1))) { - $get_child_terms = arg(1); + // Check if we're on a faq page. + if (arg(0) == 'faq') { + // Check if we're on a categorized faq page. + if (is_numeric(arg(1))) { + $get_child_terms = arg(1); + } + } + // Force some settings in case we're processing a special faq question list + // created by a custom call to faq_page(). + elseif (!empty($parent_term)) { + $get_child_terms = $parent_term->tid; + $show_term_page_children = TRUE; } + // Configure "back to top" link. $back_to_top = faq_init_back_to_top($this_page); @@ -130,7 +142,7 @@ function template_preprocess_faq_categor // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) { - $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_inline', $default_weight, $default_sorting, $category_display, $variables['class']); + $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_inline', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } if (!count($data)) { Index: includes/faq.questions_top.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/faq/includes/Attic/faq.questions_top.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 faq.questions_top.inc --- includes/faq.questions_top.inc 21 Dec 2008 18:58:26 -0000 1.1.2.5 +++ includes/faq.questions_top.inc 30 Dec 2008 17:05:10 -0000 @@ -57,6 +57,7 @@ function template_preprocess_faq_categor $data = $variables['data']; $category_display = $variables['category_display']; $term = $variables['term']; + $parent_term = $variables['parent_term']; $class = $variables['class']; // Fetch configuration. @@ -76,8 +77,18 @@ function template_preprocess_faq_categor } $this_page = $_GET['q']; $get_child_terms = 0; - if (arg(0) == 'faq' && is_numeric(arg(1))) { - $get_child_terms = arg(1); + // Check if we're on a faq page. + if (arg(0) == 'faq') { + // Check if we're on a categorized faq page. + if (is_numeric(arg(1))) { + $get_child_terms = arg(1); + } + } + // Force some settings in case we're processing a special faq question list + // created by a custom call to faq_page(). + elseif (!empty($parent_term)) { + $get_child_terms = $parent_term->tid; + $show_term_page_children = TRUE; } // Configure "back to top" link. @@ -128,7 +139,7 @@ function template_preprocess_faq_categor // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) { - $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top', $default_weight, $default_sorting, $category_display, $variables['class']); + $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); } if (!count($data)) { @@ -177,6 +188,7 @@ function template_preprocess_faq_categor $data = $variables['data']; $category_display = $variables['category_display']; $term = $variables['term']; + $parent_term = $variables['parent_term']; $class = $variables['class']; // Fetch configuration. @@ -204,8 +216,18 @@ function template_preprocess_faq_categor $this_page = $_GET['q']; $get_child_terms = 0; - if (arg(0) == 'faq' && is_numeric(arg(1))) { - $get_child_terms = arg(1); + // Check if we're on a faq page. + if (arg(0) == 'faq') { + // Check if we're on a categorized faq page. + if (is_numeric(arg(1))) { + $get_child_terms = arg(1); + } + } + // Force some settings in case we're processing a special faq question list + // created by a custom call to faq_page(). + elseif (!empty($parent_term)) { + $get_child_terms = $parent_term->tid; + $show_term_page_children = TRUE; } // Configure "back to top" link. @@ -220,7 +242,7 @@ function template_preprocess_faq_categor // Configure sub-category bodies (theme recursively). $variables['subcat_body_list'] = array(); if (($get_child_terms && $category_display == 'categories_inline') || ((($show_term_page_children && $this_page != 'faq') || $hide_child_terms) && $category_display == 'hide_qa')) { - $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top_answers', $default_weight, $default_sorting, $category_display, $variables['class']); + $variables['subcat_body_list'] = faq_get_child_categories_faqs($term, 'faq_category_questions_top_answers', $default_weight, $default_sorting, $category_display, $variables['class'], $parent_term); }