? apachesolr_281810_limit_cck_facets.patch
? limit_cck_blocks.patch
Index: apachesolr.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/apachesolr/apachesolr.module,v
retrieving revision 1.1.2.32
diff -u -p -r1.1.2.32 apachesolr.module
--- apachesolr.module	16 Sep 2008 11:26:58 -0000	1.1.2.32
+++ apachesolr.module	18 Sep 2008 18:02:34 -0000
@@ -62,6 +62,25 @@ function apachesolr_settings() {
     '#options' => $options,
     '#description' => t('The number of results that will be shown per page.'),
     );
+  if ($fields = apachesolr_cck_fields()) {
+    $current_settings = variable_get('apachesolr_cck_facets', array());
+    $options = array();
+    foreach ($fields as $name => $field) {
+      $label = db_result(db_query("SELECT label FROM {node_field_instance} WHERE field_name = '%s'", $name));
+      $options[$name] = $label;
+      if(!array_key_exists($name, $current_settings)) {
+        $current_settings[$name] = $name;
+      }
+    }
+    variable_set('apachesolr_cck_facets', $current_settings);
+    $form['apachesolr_cck_facets'] = array(
+      '#type' => 'checkboxes',
+      '#title' => t('CCK fields to display as facets'),
+      '#default_value' => variable_get('apachesolr_cck_facets', array()),
+      '#options' => $options,
+      '#description' => t("These will be available as blocks on the !block_administration_page.", array('!block_administration_page' => l(t('block administration page'), 'admin/build/block'))),
+    );
+  }
   return system_settings_form($form);
 }
 
@@ -422,11 +441,14 @@ function apachesolr_block($op = 'list', 
       $blocks['uid'] = array('info' => $author_title);
 
       if ($fields = apachesolr_cck_fields()) {
+        $cck_facets = variable_get('apachesolr_cck_facets', '');
         foreach ($fields as $name => $field) {
-          $index_key = apachesolr_index_key($field);
-          $label = db_result(db_query("SELECT label FROM {node_field_instance} WHERE field_name = '%s'", $name));
-          // TODO: $index_key must be wrong here.
-          $blocks[$index_key] = array('info' => t('ApacheSolr: Filter by @field', array('@field' => $label)));
+          if ($cck_facets[$name] != '0'){
+            $index_key = apachesolr_index_key($field);
+            $label = db_result(db_query("SELECT label FROM {node_field_instance} WHERE field_name = '%s'", $name));
+            // TODO: $index_key must be wrong here.
+            $blocks[$index_key] = array('info' => t('ApacheSolr: Filter by @field', array('@field' => $label)));
+          }
         }
       }
       
