Hi, everyone. I have been learning drupal for two weeks and now have encountered a problem that has fazed me several days.
The problem is in the attempt of modifying the search module form. Specifically, you know that the "advanced search" frame in the search module provides a dropdown list "Only in the category(s)" and a multiple check box "Only of the type(s)", from which you can specify the search scope.
But, by default "Only in the category(s)" will list all the vocabularies and terms in taxonomy, while "Only of the type(s)" will list all the content types existing in the system. Therefore, I want to efface some of the unnecessary items in the two lists. But, I don't know how to do.
I have search intensively in my drupal folder, but find no clue about "advanced search" at all. And, searching Internet returns me no valuable result, neither.
Thanks for your help~
Comments
Use Hook_form_alter
Hi,
You can use hook_form_alter (http://api.drupal.org/api/function/hook_form_alter/6) to alter the form and reset option values from the drop down
thanks for your reply very
thanks for your reply very much~
yes, I have tried hook_form_alter, but I am not sure which form to intercept, "search_block_form" or "search_form"?
Actually, I have tried both of them, but it seems that only the three normal search fields: the label showing "Search this site:", the textfield for key word input, and the submit button, can be captured. While no field of the advanced search part is relayed into hook_form_alter.
It's search_form only
Just try it, you can see all fields
thanks. but still don't work;
thanks. but still don't work; the follows are what are returned:
Array
(
[#action] => /baibao/search/node
[#attributes] => Array
(
[class] => search-form
)
[module] => Array
(
[#type] => value
[#value] => node
)
[basic] => Array
(
[#type] => item
[#title] => Enter your keywords
[inline] => Array
(
[#prefix] =>
[#suffix] =>
[keys] => Array
(
[#type] => textfield
[#title] =>
[#default_value] =>
[#size] => 40
[#maxlength] => 255
)
[processed_keys] => Array
(
[#type] => value
[#value] => Array
(
)
)
[submit] => Array
(
[#type] => submit
[#value] => Search
)
)
)
[#parameters] => Array
(
[0] => search_form
[1] => Array
(
[storage] =>
[submitted] =>
[post] => Array
(
)
)
[2] =>
[3] =>
[4] => node
)
[#build_id] => form-54968560bd48e285a68eee788f06e1d7
[#type] => form
[#programmed] =>
[form_build_id] => Array
(
[#type] => hidden
[#value] => form-54968560bd48e285a68eee788f06e1d7
[#id] => form-54968560bd48e285a68eee788f06e1d7
[#name] => form_build_id
)
[#token] => search_form
[form_token] => Array
(
[#id] => edit-search-form-form-token
[#type] => token
[#default_value] => 80659d61db67febf821106988b706539
)
[form_id] => Array
(
[#type] => hidden
[#value] => search_form
[#id] => edit-search-form
)
[#id] => search-form
[#description] =>
[#required] =>
[#tree] =>
[#parents] => Array
(
)
[#method] => post
[#validate] => Array
(
[0] => search_form_validate
)
[#submit] => Array
(
[0] => search_form_submit
)
)
This is what i got, Make sure
This is what i got,
Make sure you have enabled advanced search
I think I have (finally) find
I think I have (finally) find the problem. The advanced form is altered in node.module instead of search.module. I'm now trying to make the modification.
Thanks for your help, friends~
sorry, what do you mean by
I think I have (finally) find the problem. The advanced form is altered in node.module instead of search.module. I'm now trying to make the modification.
Thanks for your help, friends~
Hi pseudoking - have you been
Hi pseudoking - have you been able to figure this out? I too am trying to change the advanced search form but am having not much luck.
I had the same problem until
I had the same problem until I realized there was apparently a syntax problem with the 'case' statement in my hook_form_alter (if you're using 'case', it might help). It used to be :
Changing it to the following made the second case (the search_form one) work as expected:
To remove some content types from advanced search but still allow the administrator to use them, I did this:
Hope it helps.
:)
yes it helps, thanks @talino
//trying to answer one question for each one that i make.
//this way, drupal will be more friendly and strong