1

I've got thousands of nodes which were created by importing using a Feeds module. I only want them to be searchable via the views search form, not by the built-in site search.

Is it possible to disable these nodes from being searchable by the built-in search, while still making it available to the search generated by a View?

2 Answers 2

3

There are two modules you can check out.

Search Config

Restrict search results by the content type. This is a role based restriction.

Search Restrict

Restrict by role who can search for each content type.

Approach of this module is to re-write the search query, so that content is indexed and available as search results to users in role(s) that have permissions to view it, but not displayed to other roles.

OR

You can write your own query alter function.

function mymodule_query_alter(&$query) {
  $is_search = FALSE;
  foreach ($query->getTables() as $table) {
    if ($table['table'] == 'search_index') {
      $is_search = TRUE;
    }
  }

  if ($is_search) {
    $query->condition('n.type', 'node-type-name', '<>');
  }
}

And yes as webkenny suggested Custom Search as well.

Basic options

The module adds options to select:

  1. which content type(s) to search,
  2. which specific module search to use (node, help, user or any module that implements search),
  3. advanced criteria

For all these choices, there are options to switch between a select box, checkboxes or radio buttons, and also customize the selector label and the default - Any - text.

1
  • You totally won this one. ;)
    – webkenny
    Commented Feb 1, 2013 at 6:36
1

As we say in this community, "There's a module for that" - http://drupal.org/project/custom_search

Good module to add-on if you're using the core search module. Won't affect your views in any way since those are two different flows.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.