By arnoldc on
I try to limit number of content types in the basic search box and can't get it to work. It still returns everything to me. Is it because I am using "search-theme-form" and the filtering only works in "search-form". I went through the threads but was confused even further by the difference in Drupal 5 and 6. I am themeing the basic search box in my own search-theme-form.tpl.php and here is the generated HTML codes for the search box.
Essentially, I added the last line to allow search only for my content type called "page_content" but it is not working.
<form action="/homepage" accept-charset="UTF-8" method="post" id="search-theme-form">
<div>
<div class="form">
<input type='text' class='text' name='search_theme_form' id='edit-search-theme-form-1' value='Search Text'/>
<input type='image' class='button' name='op' id='edit-submit' src='/sites/all/themes/my-style1/images/go-button.gif'/>
<input type="hidden" name="form_build_id" id="form-f754c85cb95740deeaa827f49dd79982" value="form-f754c85cb95740deeaa827f49dd79982" />
<input type="hidden" name="form_id" id="edit-search-theme-form" value="search_theme_form" />
<input type="hidden" name="type[page_content]" id="edit-type-page_content" value="page_content" />
</div>
</div>
</form>
Comments
Bump. Anyone?
Bump. Anyone?
Okay, two issues I think. 1.
Okay, two issues I think.
1. search_theme_form probably doesn't take the extra fields so I have to resort to use either search_block_form or search_form.
2. make sure to grant "use advanced search" permission or the search won't work.
So add this form to your template and it should do the trick. In this example, search in "page_content" and "news_article" types only.
Now I have to figure out how to add Taxonomy filtering in the form. I couldn't figure out what to put in the form based on advanced form or is it possible at all. Anyone?
I am surprised Drupal's core search is not very flexible and not so easy to customize.....
This search box works in D6.
Okay, may not be pretty but got it to work.
By placing the following simple search box in my page template, I can search contents by my specific content types and categories. Do not use search_theme_form as it doesn't work with advanced search functions.
does this only work for logged in users?
Doesn't seem to jive for me when I'm not logged in. Boo-urns.
J
it works for everybody!
My bad -- this was a simple conflict with Search Config module.
J
I have the same problem the
I have the same problem the snippet above works fine when I'm logged but not for Anonymus user.
Have I to set "advance search" for all users?
Same here
The same problem here. Doesn't work for anonymous user.
http://www.submit.dk/drupal
Solved with Search Config
Solved with Search Config module