views:

29

answers:

1

I have created a search page uising exposed filters and views module. The user can choose from different values in order to get a table with specific results (returning node fields). This page is located under mysite.com/search. The problem is that I would like to put a simplified version of the search form on my homepage (lets say just the keyword search box + one or two checkboxes). This can be a block or a view. When the user presses the search button I would like to redirect him to the search page and show the results. Here the user shall be able to refine his search in an ordinary way. I guess this can be achieved by HTTP GET parameters and pointing to the actual search site. I was wondering however if I could do it without hardcoding the forms on my homepage, i.e. by using views, blocks, etc. I hope this makes sense. Any help will be appreciated.

+1  A: 

Edit

The end result is that you want to have one form bring you to the search results page, and another advanced form on the search results page itself. This solution accomplishes this by creating two identical views with different filters for each form.

When someone uses the simplified form, they're taken to example.com/search, and when they're on that page and use the advanced form, they're taken to example.com/search/advanced. Because the views are identical with similar paths, the end user won't know the difference.

Here's how to accomplish this:

  1. Create a view for the search results. Use the default display to set up the search results however you want. For filters, only put in automatic filters: don't put in the stuff you want the user to be able to filter by.
  2. Create a new page display in that view. Give it a path of search. This is going to be the results page that a user hits when they use your simplified search form.
  3. In this page display, override the filters. Set up and expose the filters you want for the simplified search form.
  4. Override Expose form in block in the Basic settings for this display and set it to yes.
  5. Create a new page display in the view, and give it a path of search/advanced. This is going to be the results page that a user hits when they use the advanced search form.
  6. Override the filters for this display, set up and expose the filters you want for the advanced search form.
  7. Override Expose form in block in the Basic settings for this display and set it to yes.

Now, you'll have two view pages, search and search/advanced, and two blocks, a simplified search form and an advanced search form.

Go to the block administration, and enable the simplified search block. Use the path specific visibility settings to set where you want the simplified search box to appear.

Now, enable the advanced search block. Use the path specific visibility settings to set the visibility to:

search
search/*

Let's say you wanted to create another simplified search block with a different set of filters (let's call this alternate). You can do that too: create another page display in your view as you did in steps 2-4 but instead of using the path search, give it a different path: search/alternate. You can add as many simplified forms with different filters as you want, and they'll all have the advanced search form and the same results when you use them.

Mark Trapp
Thanks for your answer, but I dont quite get it. Do I have to create 2 views?Or 2 blocks? Currently I have default and page displays. Should I create a block display or create new view? Also when I remove fields from block display, they are also removed from Page display(advanced results page) In my Page display I am displaying both search form and results(via fields) and I would like to have mini search box on my homepage with a few forms that takes the user to the advanced (page display) results.
Vafello
I rewrote my solution to hopefully be a lot more clear.
Mark Trapp
That's exactly what I wanted. It simply a kick-ass solution by a real drupal-expert! You should write an article on that, I think quite a lot of drupal users would be thankful.Thanks a lot!!
Vafello

related questions