There is some way to somehow, make the "Search form" block to use (redirect it) my new "search page" (already filtered with the bundle:book) ?

It seems that the default action for the Search form block is to search on /search/site, and i would like, in certain site sections, make it search on /search/docs (as i named it...)

Comments

nick_vh’s picture

Would a possible solution be a configuration option in the search block asking to what page you want to submit it to?

If you want to do it yourself you should probably write a submit handler for the search form and reset the redirect there
my_module_form_search_submit()

nick_vh’s picture

function my_module_form_search_block_form_alter($form, &$form_state) {
  $form['#submit'][] = 'my_module_search_block_form_submit';
}

function my_module_search_block_form_submit($form, $form_alter) {
  //modify the redirect path here
}

This should work,

nick_vh’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

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

drewmacphee’s picture

Category: support » feature
Status: Closed (fixed) » Active

Wouldn't it be better for each search page to have it's own search form block?

nick_vh’s picture

Yes it would be,

but we are in search of people that would love to create this functionality. Are you interested? :-)

mtift’s picture

@Nick_vh I would be interested in help with this. Do you have a general idea about how you would like it to work?

nick_vh’s picture

There is a tab search pages/blocks.

I'd love to see this decoupled and an easy way to manage search blocks/clone search blocks in the same manner as possible with the more like this block. However, we do not aim to replicate "views" alike blocks so the specs of each block should be well defined

For now we can start with making the search block a bit more dynamic and then hook into this cleaner function to make different versions of them

nick_vh’s picture

Status: Active » Needs work

This is already implemented in 6.x-3.x. It could be as simple as a small config in the settings tab

tobi20’s picture

I would like to help with this. Is this just a port of 6.x-3.x to 7.x-1.x? Any ideas where I should start?

nick_vh’s picture

tobi, yes you could try to do something similar?

Let us know how you are progressing! Thanks

luco’s picture

hey there,

has any progress been made in this regard?

cheers,
Luciano

luco’s picture

hey there,

I've studied your code from versions 6.x-3.x and 7.x-1.x and ported that functionality. please test the patch.

I realise it's not the decoupling - yet! - but at least users can have a choice of search page redirection. ;)

cheers,
Luciano

Daniel Schaefer’s picture

Thanks a million, luco. Works like charme on my D7

luco’s picture

glad to hear! :) not sure this contribution is what the maintainers are after, but let's hope it gets incorporated.

subhojit777’s picture

I tested the patch submitted in #13. It is working alright when I select Core Search or a custom search page. However, there is some error when I select drupal core search. On selecting drupal core search I am getting page not found and an error:

Notice: Undefined index: drupal_core in apachesolr_search_form_search_submit() (line 1559 of /var/www/test_site/sites/all/modules/custom/apachesolr/apachesolr_search.module).

subhojit777’s picture

@luco I saw your patch, in apachesolr_search.admin.inc you are doing:
$options['drupal_core'] = t('Drupal Core Search');
Is this necessary? You can configure default search from admin/config/search/settings, so I guess Drupal core search option is not necessary in the admin form.

subhojit777’s picture

@luco I have made certain changes to your patch. I am removing this option:
$options['drupal_core'] = t('Drupal Core Search');
because I think it is not necessary, and a similar setting already exists in default drupal search.

subhojit777’s picture

Status: Needs work » Needs review
StatusFileSize
new2.25 KB

Very sorry. Patch not uploaded correctly. Uploading it again.

nick_vh’s picture

Status: Needs review » Needs work
@@ -40,10 +40,27 @@ function _apachesolr_search_browse_form($default_value) {
+function apachesolr_search_pages_config_form() {

needs a docblock above the function

@@ -40,10 +40,27 @@ function _apachesolr_search_browse_form($default_value) {
+    '#type' => 'radios',

Why not a select list? This could grow extensively if there are many pages?

@@ -40,10 +40,27 @@ function _apachesolr_search_browse_form($default_value) {
+    '#default_value' => variable_get('apachesolr_search_default_search_page', 'drupal_core'),

drupal_core is not a valid default search page, Better would be to take the first one from the list with a preference for drupal_core. I think we'll make it possible soon to remove that one page. A little further you use the variable to define this default page with the apachesolr_search_default_search_page() function.

@@ -40,10 +40,27 @@ function _apachesolr_search_browse_form($default_value) {
+    '#description' => t('Makes the search block submit to Apache Solr Search'),

Description is not super clear, can you improve this?

@@ -1552,7 +1552,21 @@ function apachesolr_search_form_search_submit($form, &$form_state) {
+    if (substr($search_path, -1) == '%') {

Can you add some documentation here?