Is there a simple way to create a search box that only returns results from one content type?

Comments

cwgordon7’s picture

You could create a view that shows all the nodes, filtered to the node type you want. Then add the filter Search:Index, and expose it. The user will see all nodes of that type, and be able to search through them. This is all without you doing any sort of coding.

-cwgordon7

Drupalzilla.com’s picture

Thanks for the tip. I need a search box on the front page though -- it should say "search for businesses", and be limited to the content type called "business".

--
http://drupalzilla.com/ — Drupal SEO

cwgordon7’s picture

You could use the same idea in the last comment. Create a view, with the filter node:type and then select businesses, set the header of the block to "Search for businesses", and include a search:index exposed filter.

Drupalzilla.com’s picture

I experimented with that, but I'm not sure how to prevent it from listing the nodes.

Is there a way to have a simple search box that when you enter a search query it takes the user to the search results page? It shouldn't list the results on the front page.

(example.com/search/)

greg.harvey’s picture

You can do it with hook_form_alter. See my comment under the search block snippet:
http://drupal.org/node/141788#comment-730057

cashwilliams’s picture

I'm was trying to do what you suggested as it sounds like exactly what I'm looking for, but search:index isn't in my filter types. any ideas?

Screen of options - http://twitpic.com/1pnqd

lookatyeti’s picture

There is a module that might work for you: http://drupal.org/project/search_config

After you install it go to the search settings and there will be an advanced drop down at the bottom of the page, you can then limit the search results by content type.