aneuryzm
aneuryzm

Reputation: 64834

Drupal: can I specify a View for my search results?

I have a "Search" field in my website and I was wondering if I can assign my View to the search results, instead of using the default list.

Is this feasible ? How ?

thanks

Upvotes: 3

Views: 4398

Answers (4)

lorenzo
lorenzo

Reputation: 41

It is possible to handle the search output by a view using the default search forms without exposing filters:

  1. create a view of type content which displays all content types, display page
  2. set Path: /search/node/%
  3. add Contextual Filter "Search: Search Terms", then set "Provide default value" and "Raw value from URL" and "Path Component" to "3".

Now, every time you search for a node your view gets called instead of the default search result page because it is using the same path than the default search. The % is the argument which is handled by the Contextual Filter. Do not forget to set the filter to the 3rd component of the path which is the placeholder "%".

Upvotes: 4

aneuryzm
aneuryzm

Reputation: 64834

I've actually found the item "Search" in my Filters options in Views. I dunno how I could ignored it before. It actually exists, and works quite well. Solved.

Upvotes: 1

Chaulky
Chaulky

Reputation: 699

You can replace the default Search with a Views search instead. I haven't done this personally, but from what I've read it sounds straight forward. Create your "Search" View, then display it's "exposed filter" form instead of the default search form. More details here... http://groups.drupal.org/node/18582

Or, if you just want to make the search results look different, you can simply theme them, instead of using Views to do the searching. You can also control what fields (CCK and such) get displayed in the search results on the Display Fields > Search tab when editing the content type. I don't know the name of the template file for themeing search results of the top of my head, but if you have Theme Developer installed you can easily figure this out.

Upvotes: 1

googletorp
googletorp

Reputation: 33275

You can use views to do search with exposed filters etc, but this is not a functionality that you can put on the search you have already. You can create a block in your search view and with theming replace what you got now with it instead.

This probably requires some work since the search box is usually not located in a region.

Upvotes: 0

Related Questions