Question

Situation: In Drupal, when you use Views module, it restricts to display Search Form and Results on the same page.

E.g. Page A = (Search Form + Results).

There is no option in Views module interface to move/copy Search Form to another page. E.g. Page A = Search Form, Page B = Results Form

Question: Is it allowed by Views architecture if I have a separate Filter(Search) Form on site front page, and this form then submits search params to actual view page (which displays Results).

My original goal was to have simple search on the 1st page and then results are displayed I would show advanced search form on the second page.

Naturally, I am going to make the 1st custom form have identical fields as in original filter form so that view would understand them.

Is it a typical/accepted solution?

Was it helpful?

Solution

Short answer

This is automated with the Exposed form in block setting in Views.

Longer Answer

If you want to do it from within views, set Exposed form in block under Basic Settings to "Yes". This will create a block with all the exposed filter forms. As a block you can define what region it will appear in, and on which pages.

The form in the block submits a GET request to the URL of your page view, with the query string set by the form elements you define in your exposed filters.

For example, if you create an exposed search on node title, and retain the default Filter Identifier of "title", you can always craft your own form that posts to /searchview?title=blah. I'd stick with the blocks system, myself.

OTHER TIPS

I can't really understand that well what you mean.

A search form that sends data to another page is perfectly compatible with the MVC pattern, as long as you keep intrests separated (databse interaction in the model, data manipulation in the controller and html in the view).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top