Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Julien PHAM on
Hi,
When I do a search in my whole site, it searchs for all content types. And if I ask for an advanced search, I can choose the content type I would like to search in.
I don't like that, I would like the user not beeing able to choose which content type he will search in, and force him to search only in some content type.
Is there a way to do this?
Thanks
Comments
Yes, but requires programming
You would need to implement hook_search to search only on the node type you're interested in, and then call search_box() with the parameter 'search/yourtype'. In other words, the tools are there for programmers, but there is no UI to do this.
- Robert Douglass
-----
My Drupal book: Building Online Communities with Drupal, phpBB and WordPress
Can you give an example?
I'm stuck on this as well. This seems like such a basic functionality - to be able to search say, only movierevies or only with a forum. Is there a way to do it with taxonomy instead?
Altervatively, I know some basic PHP - enough to have create some of my own basic mods on drupal and other systems. Your answer above doesnt' really tell me where to start - do I need to create a new module, or is this php that can go directly into a page. (I would like, for instance, a way to search just the forums, from the forum home page. This would be seperate from the "Search this site" function that would search everything.)
appreciate your help.
(ps I see the help section on searches, and in particular the hook_search here: http://api.drupal.org/api/4.7/function/hook_search bit it doesn't help me to understand how it is implemented. In the example they give, they say they use node.module - but I can't see where in the code it references that)