Upgrade Your Drupal Skills

We trained 1,000+ Drupal Developers over the last decade.

See Advanced Courses NAH, I know Enough

Split a Views Exposed Form into Multiple Blocks

Parent Feed: 

Submitted by Stefan Borchert on Mon, 17/06/2013 - 18:44

While working on a project for a customer we had the requirement to display different parts of an exposed form of a view in different regions of the page. Additionally not all parts of the form should be visible on all pages of the site (i.e. the search box should be visible on all pages whereas other exposed filters or sort options should be visible on the result pate only).
Normally we would manage this by using some hook_form_alter()-magic and/or create a custom block with a coded form in it. But a hint of Daniel Wehner (dawehner) pointed me to a different solution:

Multiple Views Displays

In Views you are able to clone an existing display, which means nothing else but creating a plain copy of it. In our case I cloned the page display containing the exposed form to split and modified some filter settings only. 

Other options (especially the page path) were not changed.

If you now look into the list of blocks, there is one block for both Views displays containing the corresponding exposed form. These blocks may be displayed on different pages and in different regions.

Original Post: 

About Drupal Sun

Drupal Sun is an Evolving Web project. It allows you to:

  • Do full-text search on all the articles in Drupal Planet (thanks to Apache Solr)
  • Facet based on tags, author, or feed
  • Flip through articles quickly (with j/k or arrow keys) to find what you're interested in
  • View the entire article text inline, or in the context of the site where it was created

See the blog post at Evolving Web

Evolving Web