--- faceted_search_ui_0.module	2008-07-03 11:28:33.000000000 +0200
+++ faceted_search_ui.module	2008-07-03 11:36:08.000000000 +0200
@@ -90,6 +90,11 @@
       if (faceted_search_variable_get($env_id, 'sort_block', TRUE)) {
         $blocks[$env_id .'_sort'] = array('info' => t('@env - Sort options', array('@env' => $env)));
       }
+      if (faceted_search_variable_get($env_id, 'separate_guided_blocks', FALSE)) {
+        foreach (faceted_search_load_filter_settings($env_id) as $index => $filter) {
+          $blocks[$env_id .'_guided_'. $index] = array('info' => t('@env - Guided search for @filter', array('@env' => $env, '@filter' => $index)));
+        }
+      }
     }
     return $blocks;
   }
@@ -97,7 +102,7 @@
     global $_faceted_search;
     
     // Determine the environment id and requested block.
-    list($env_id, $delta) = explode('_', $delta, 2);
+    list($env_id, $delta, $filter_name) = explode('_', $delta, 3);
 
     if (!isset($_faceted_search[$env_id]) && $delta != 'related') {
       // Initialize the current search. This case only happens when the block
@@ -105,7 +110,7 @@
       $_faceted_search[$env_id] = new faceted_search($env_id);
       $_faceted_search[$env_id]->ui_state = _faceted_search_ui_defaults();
     }
-    
+
     faceted_search_ui_add_css();
     switch ($delta) {
       case 'current':
@@ -123,7 +128,7 @@
       case 'guided':
         if ($_faceted_search[$env_id]->ui_state['stage'] == 'results') {
           $block['subject'] = t('Guided search');
-          $block['content'] = faceted_search_ui_guided_block($_faceted_search[$env_id]);
+          $block['content'] = faceted_search_ui_guided_block($_faceted_search[$env_id], $filter_name);
         }
         break;
 
@@ -259,6 +264,12 @@
       '#description' => t('Check this option to have tooltips displayed with subcategories when hovering over a category in the Guided search. This feature works only with clients that have JavaScript enabled, but is unobtrusive to clients that lack JavaScript.'),
       '#default_value' => faceted_search_variable_get($env_id, 'tooltips', FALSE),
     );
+    $form['guided']['separate_guided_blocks'] = array(
+      '#type' => 'checkbox',
+      '#title' => t('Provide seperate blocks for every facet'),
+      '#default_value' => faceted_search_variable_get($env_id, 'separate_guided_blocks', FALSE),
+      '#description' => t('When enabled, blocks for every category will be provided.'),
+    );
 
     // Related categories block section.
     $form['related'] = array(
@@ -533,7 +544,7 @@
 /**
  * Display the faceted browser.
  */
-function faceted_search_ui_guided_block($search) {
+function faceted_search_ui_guided_block($search, $facet_name = NULL) {
   faceted_search_ui_add_tooltips($search->get_env_id());
   
   $facet_content = array();
@@ -541,19 +552,20 @@
     if (!$facet->is_browsable()) {
       continue; // Not a facet.
     }
-
-    if ($facet->get_max_categories() > 0) {
-      $max_count = $facet->get_max_categories();
-    }
-    else {
-      $max_count = NULL; // No limit.
-    }
+    if ((!empty($facet_name) && $facet_name == $facet->_field['field_name']) || !$facet_name) {
+      if ($facet->get_max_categories() > 0) {
+        $max_count = $facet->get_max_categories();
+      }
+      else {
+        $max_count = NULL; // No limit.
+      }
     
-    $categories = faceted_search_ui_build_categories($search, $index, 0, $max_count);
-    if (count($categories) > 0 || $facet->is_active()) {
-      $content = theme('faceted_search_ui_facet_heading', $search->get_env_id(), $search->ui_state, $search->get_filters(), $index, 'guided');
-      $content .= theme('faceted_search_ui_categories', $facet, $categories, $search->ui_state['stage']);
-      $facet_content[] = theme('faceted_search_ui_facet_wrapper', $search->get_env_id(), $facet, 'guided', $content);
+      $categories = faceted_search_ui_build_categories($search, $index, 0, $max_count);
+      if (count($categories) > 0 || $facet->is_active()) {
+        $content = theme('faceted_search_ui_facet_heading', $search->get_env_id(), $search->ui_state, $search->get_filters(), $index, 'guided', empty($facet_name));
+        $content .= theme('faceted_search_ui_categories', $facet, $categories, $search->ui_state['stage']);
+        $facet_content[] = theme('faceted_search_ui_facet_wrapper', $search->get_env_id(), $facet, 'guided', $content);
+      }
     }
   }
   return theme('faceted_search_ui_guided_search', $search, $facet_content);
