For environments it's easy to inject some custom settings using form_alter that get serialized to database.
But it's not easily possible to add custom settings to search pages. These settings are serialized to the database as well and would be a perfect place for some custom search page settings

I created a small patch that allows contrib modules to do so easily.

Motivation: Apache Solr Multilingual currently has some global configurations for the default search index / environment and for the default search page. In order to support multiple environments and multiple search pages we need to store individual settings.

Files: 
CommentFileSizeAuthor
#9 1918030-D6-9.patch2.64 KBpwolanin
PASSED: [[SimpleTest]]: [MySQL] 570 pass(es). View
#4 1918030-4.patch2.64 KBpwolanin
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1918030-4.patch. Unable to apply patch. See the log in the details link for more information. View
#1 1918030_add_custom_settings_to_search_pages.patch807 bytesmkalkbrenner
PASSED: [[SimpleTest]]: [MySQL] 513 pass(es). View

Comments

mkalkbrenner’s picture

Status: Active » Needs review
FileSize
807 bytes
PASSED: [[SimpleTest]]: [MySQL] 513 pass(es). View
klonos’s picture

pwolanin’s picture

Status: Needs review » Needs work

We can instead set #tree on the advanced section?

pwolanin’s picture

Status: Needs work » Needs review
FileSize
2.64 KB
FAILED: [[SimpleTest]]: [MySQL] Unable to apply patch 1918030-4.patch. Unable to apply patch. See the log in the details link for more information. View
Nick_vh’s picture

Looks good to me

mkalkbrenner’s picture

The patch for Apache Solr Multilingual to use #4 instead of #1:

diff --git a/apachesolr_multilingual.module b/apachesolr_multilingual.module
index 2c5363c..3c6b938 100644
--- a/apachesolr_multilingual.module
+++ b/apachesolr_multilingual.module
@@ -498,6 +498,7 @@ function apachesolr_multilingual_form_apachesolr_search_page_settings_form_alter
 
   $form['apachesolr_multilingual_query_settings'] = array(
     '#type' => 'fieldset',
+    '#tree' => TRUE,
     '#title' => t('Multilingual Query Settings'),
     '#collapsible' => TRUE,
     '#collapsed' => TRUE,
@@ -535,16 +536,7 @@ function apachesolr_multilingual_search_page_settings_form_validate($form, &$for
  * Processes apachesolr_search_page_settings_form form submissions.
  */
 function apachesolr_multilingual_search_page_settings_form_submit($form, &$form_state) {
-  if (empty($form_state['search_page_custom_settings'])) {
-    $form_state['search_page_custom_settings'] = array();
-  }
-
-  $form_state['search_page_custom_settings'] +=
-    array(
-      'apachesolr_multilingual_auto_language_filter' => $form_state['values']['apachesolr_multilingual_auto_language_filter'],
-      'apachesolr_multilingual_auto_language_filter_detachable' => $form_state['values']['apachesolr_multilingual_auto_language_filter_detachable'],
-      'apachesolr_multilingual_show_language_undefined_results' => $form_state['values']['apachesolr_multilingual_show_language_undefined_results'],
-    );
+  $form_state['values']['advanced'] += $form_state['values']['apachesolr_multilingual_query_settings'];
 }
 
 /**

pwolanin’s picture

Version: 7.x-1.x-dev » 6.x-3.x-dev
Status: Needs review » Patch (to be ported)

committed to 7.x

mkalkbrenner’s picture

committed #6 to Apache Solr Multilingual

pwolanin’s picture

Status: Patch (to be ported) » Needs review
FileSize
2.64 KB
PASSED: [[SimpleTest]]: [MySQL] 570 pass(es). View

here's a simple application of the patch to 6.x-3.x - needs testing.

mkalkbrenner’s picture

9: 1918030-D6-9.patch queued for re-testing.

mkalkbrenner’s picture

Assigned: Unassigned » mkalkbrenner
Issue summary: View changes

  • Commit 18af027 on 6.x-3.x by mkalkbrenner:
    Issue #1918030 by mkalkbrenner, pwolanin: Allow contrib modules to add...
mkalkbrenner’s picture

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.