Search bar not working after enabling Search Config...
wflorian - December 6, 2008 - 17:55
| Project: | Search config |
| Version: | 5.x-1.4 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | critical |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Description
Hello,
I have a search bar which has the following code:
<input type="text" maxlength="128" name="search_theme_form_keys" id="edit-search-theme-form-keys" size="20" value="" title="Suchbegriff eingeben und Enter drücken!" class="form-text" /></div>
<input type="submit" name="op" id="edit-submit" value="" class="form-submit" />
<input type="hidden" name="form_token" id="edit-search-theme-form-form-token" value="<?php print drupal_get_token('search_theme_form'); ?>" />
<input type="hidden" name="form_id" id="edit-search-theme-form" value="search_theme_form" />After enabling the Search Config module, the search using the search bar isn't working anymore. I get redirected to www.XXX.de/search but I have to enter the word again to get a result...
Can you tell me what the Search Config module does to the standard search so that my search bar isn't working anymore? Any suggestions for changing my code on the search bar?
Thank you in advance.
Regards
Florian

#1
here is the code from the template.php
function phptemplate_search_theme_form($form) {return _phptemplate_callback('search-theme-form', array('form' => $form));
}
i guess i have something to change here. can you tell me what?
i figured out that it probably has something do with the "Default Search" setting. but my php skills are very very limited. as i wrote, i guess it has something do with the code in the template.php?
#2
wflorian,
I am not sure what the issue is but it probable has something to do with the HTML snippet. Search config should not affect the search form in the way you described. Try disabling the module and see if the problem is still there.
#3
no disabling the modul makes the problem go away. it has something to do with the module.
in fact i tried around with the search_config.module, and deleted the following lines
Line 13-20:
/**
* Implementation of hook_perm()
*
* Allow the displaying of form fields per role.
*/
function search_config_perm() {
return array('search by node type', 'search by category', 'use keyword search');
}
Line 26-37:
// Present the user with the appropriate search results tab as defined by
// variable "search_config_default_search" (labeled "Default Search")
// in the "Advanced search settings" fieldset in admin/settings/search
if ($form_id == 'search_theme_form') {
$form['#submit'] = array();
$form['#submit']['search_form_submit'] = array();
$form['module']['#value'] = variable_get('search_config_default_search', 'node');
$form['module']['#type'] = 'hidden';
$form['processed_keys'] = $form['search_theme_form_keys'];
$form['processed_keys']['#weight'] = -1;
unset($form['search_theme_form_keys']);
}
After that the searchbar worked. So it has something to do with option 'search by node type', 'search by category', 'use keyword search'.
I didn't change the search option in the admin menu. The option 'search by node type' is activated, but the searchbar does not work. So I guess that in the template.php there has to be made some code arrangements
function phptemplate_search_theme_form($form) {
return _phptemplate_callback('search-theme-form', array('form' => $form));
}
..like i said, i am not a php pro and my knowledge in php is very limited...
I would be really glad if you could help me solve the problem.
Is there a possibilty to remove the option "'search by node type', 'search by category', 'use keyword search'"?
Florian
#4
> Is there a possibilty to remove the option "'search by node type', 'search by category', 'use keyword search'"?
You can disable the advanced search.
#5
Hello canen.
I am sorry. I think I got some things wrong. Following code does not do anything:
function search_config_perm() {
return array('search by node type', 'search by category', 'use keyword search');
}
BUT removing this code, does make the searchbar work again: (Line 29-37)
if ($form_id == 'search_theme_form') {$form['#submit'] = array();
$form['#submit']['search_form_submit'] = array();
$form['module']['#value'] = variable_get('search_config_default_search', 'node');
$form['module']['#type'] = 'hidden';
$form['processed_keys'] = $form['search_theme_form_keys'];
$form['processed_keys']['#weight'] = -1;
unset($form['search_theme_form_keys']);
}
Do you have any idea, what could be the problem here? Is it safe to remove that code? What does the code do?
Thank you again for discussing the problem with me. I really hope we can get the searchbar working again. I really need the module...
Best wishes
Florian
#6
It is possible for a number of modules to implement search. That piece of code assigns the default one based on a set variable. You can change the default search on the search configuration page under the advance configuration section.
Which other modules do you have installed and what is set as the default search?
#7
Default search is "node"
There are enabled more than 15 other modules. But they are all non-search related. The search-config module is the only search related module. Like I said disabling search config makes the searchbar work again. Enabled the search bar does not work.
Could the selection of default search break the searchbar function?
#8
I am not sure. I'll need to set-up a drupal 5 environment to test. That feature is relatively new so anything is possible.
#9
wflorian,
Do you mind using the 1.3 version until I get a chance to look at this? The only difference between that 1.4 is the ability to choose the default search.
#10
hey canen,
that would be great, I tested the whole day, but couldn't get the searchbar working..
#11
I could solve the problem by replacing:
id="edit-search-theme-form-keys" name="search_theme_form_keys"
with:
id="edit-processed-keys" name="processed_keys"
now everything works fine!
#12
I can confirm that upgrading to 5.14 essentially broke the search box.
This is due to bypassing the search_box_form_submit function in the search module, which is responsible to append the keywords entered in the box to the search form URL.
<?php/**
* Process a block search form submission.
*/
function search_box_form_submit($form_id, $form_values) {
return 'search/node/'. trim($form_values[$form_id .'_keys']);
}
?>
If the search lives under "search/node", then searching for "dog" should take you to "search/node/dog", but it doesn't anymore.
As wflorian points out, the culprit is the form_altering, specifically the assignment of a different submit function "search_form_submit" and the unsetting of the "search_theme_form_keys".
Since there is no "search_form_submit" function provided, no processing is done at all by the looks of it.
Commenting out those lines fixes it, but probably breaks some search_config functionality. For now I'll roll back...I can't see how this would NOT break the search box in D5.
<?phpif ($form_id == 'search_theme_form') {
//$form['#submit'] = array();
//$form['#submit']['search_form_submit'] = array();
$form['module']['#value'] = variable_get('search_config_default_search', 'node');
$form['module']['#type'] = 'hidden';
$form['processed_keys'] = $form['search_theme_form_keys'];
$form['processed_keys']['#weight'] = -1;
//unset($form['search_theme_form_keys']);
}
?>
Happy to get involved once I understand what the form_altering is trying to achieve..."processed_keys" doesn't seem to be used anywhere else in the module. Can you give a quick explanation, canen?
Many thanks...
#13
I actually fixed this in the 6.x-dev version but I haven't backported it yet.
I left a reminder to myself here http://drupal.org/node/354817