I've changed the original flexinode_page_search_form() function to allow the use of an internal function to construct search forms that can be used within site parts.
/**
* Generates a search form, and can be used within the normal flexinode search or to
* specify diferent forms for other site sections
*/
function flexinode_generate_search_form($ctype_id, $action, $phraseSearch, $fields) {
$output = '';
$ctype = flexinode_load_content_type($ctype_id);
if ($phraseSearch) {
$output .= form_textfield(t('search for phrase'), 'search', '', 60, 128);
}
foreach ($ctype->fields as $field) {
if (!is_array($fields) || (is_array($fields) && array_search($field->field_id, $fields))) {
$output .= flexinode_invoke('search_form', $field);
}
}
$output .= form_submit(t('Search'));
return form($output, 'post', $action);
}
/**
* Menu callback; presents a search form for nodes of one type.
*/
function flexinode_page_search_form($ctype_id = 0, $phraseSearch = true, $fields = false) {
if (!$ctype_id) {
drupal_not_found();
}
if ($_POST['op'] == t('Search')) {
return flexinode_page_table($ctype_id);
}
$form_action = request_uri();
$output = flexinode_generate_search_form($ctype_id, $form_action, $phraseSearch, $fields);
$ctype = flexinode_load_content_type($ctype_id);
drupal_set_title(t('search %type', array('%type' => t($ctype->name))));
print theme('page', $output);
}
With this I can do the following:
print flexinode_generate_search_form(4, 'flexinode/search/4', false, array(58,67,68,61,62));
within the page.tpl.php, and this way I have a small search form for flexinode adapted to the site itself. I also maintain the original search form, to do "advanced" searchs!
What do you think?!
Comments
Comment #1
Bèr Kessels commentedPlease make this into a proper patch so we can review it.
Comment #2
magico commented