开发者

Filter and View screens on different pages

开发者 https://www.devze.com 2022-12-09 21:00 出处:网络
Situation: In Drupal, when you use Views module, it restricts to display Search Form and Results on the same page.

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 F开发者_StackOverflow中文版orm 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?


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.


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).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号