Form presets aka "simple advanced" form
| Project: | SQL Search (Trip Search) |
| Version: | 5.x-1.6 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
I'd like a version of the "simple" search block that includes some hard-coded (non-user-selectable) settings from the advanced search form. In particular, I'd like to give the user a form with just one text field and one button that restricts the search to only nodes tagged with one specific taxonomy. (It makes sense in my application.) The advanced form does this, no problem. I've tried it, and it works great. But an unacceptable percentage of my users brains would leak out their ears if I showed them the advanced form.
Is there a way to achieve this? I'm happy to do whatever custom coding I have to, I just can't figure out how to tackle it. I've tried theming the form, using form_alter, using drupal_execute, and even emulating the search form in HTML. No luck, probably due to my Drupal newbness.
If anyone could point me in the right direction, I'd be eternally grateful. Sample code (working or not) would be much appreciated, but just a "do it like this, stupid" would be much appreciated.

#1
After much banging of my head on the keyboard, I came up with this. It correctly gives the desired search results. I'm still working out formatting, pagination, etc. But I think it'll work out:
function _my_module_do_search() {
$form = array(
'search_form' => trip_search_form(),
);
$form_values = array(
'keys' => t('test'), // PASS IN REAL KEY VALUES HERE
'form_type' => 'advanced',
'taxonomy_operator' => '2',
'taxonomy_terms' => array(2), // USE YOUR TERM VALUE(S) HERE
'op' => 'Advanced+search',
);
// WE JUST WANT THE RESULTS PORTION OF THE RETURN VALUE.
$ret = _trip_search_do_search($form, $form_values);
$ret = $ret['results_list'];
return $ret;
}
#2
This might be useful for me too, just so you know that you didn't bang your head only for your site. ;) Good idea.