Stop Searching

There are times when you don't want people to search for specific content types. For example, you may not want to be obliged to theme a content type which is not supposed to be visible anyway, just in case it surfaces in a search. Or there may be a content type which you specifically do *not* want people to be able to search on.

There are two ways to skin this cat, that I know of at least:

1) Use hook_db_rewrite_sql to intercept the query and drop your unwanted content types from the search. I won't re-invent the wheel. Jeff Eaton at Lullabot has already written a nice "HOW TO"-style blog about it here:
http://www.lullabot.com/articles/hiding-content-drupals-search-system

2) Use the Search Config module to manage the search indexes and drop content you don't want people to search on from the index (as well as unsetting the unwanted Advanced Search checkboxes, of course):
http://drupal.org/project/search_config

There are cases where option 1) might be preferable, but not many.

If anyone knows of other/better ways, do comment! =)

Post new Comment

The content of this field is kept private and will not be shown publicly.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
  • You may post code using <code>...</code> (generic) or <?php ... ?> (highlighted PHP) tags.

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.