How to display an exposed filter as a block to create a search form block

Description

Collection: Drupal 8 Site BuildingChapter: How to customize search, run cron and improve performance

In order to mimic the search functionality that comes with core Drupal, we'll need to create block that users can search from. Here we demonstrate how to use an interesting feature to pull exposed filters into a block, and then configure the block to display both in the sidebar and above the search results.

Transcript

So this looks good, except we want to also display this form in a sidebar that shows up across the site, like the core search block here. Let's go back to our view, the way we can do this with views is by exposing the form in a block. So let's set this to "yes" instead of "no" and click "apply.

" When we do this it's going to move the exposed filter into a block, and then we'll have to manually place it where we want to display it, because it's now in a block, we're not going to see it in the preview anymore. Let's click save. Now because it's a block, we'll be able to display it in two different places, based on different criteria.

On the search page, we want to show a block at the very top, and then on every other page, we want to show a search form in a sidebar block. Let's tackle this one first, if we refresh the page we'll see that the form is gone. So let's add it back in, we'll go to the block layout page and we're going to display this above the content. ...

When you have an active membership, you will be able to see your progress here.

Skill focus: Site BuildingSkill level: Beginner - Intermediate

If you're looking to get started with Drupal 8, this is a great place to begin. In this series we build a practical Drupal 8 site from start to finish and get immersed in the most essential techniques, terminology and tools needed for both professional and hobbyist site builders. No matter how you work with Drupal 8 - as a site builder, programmer, front end developer or project manager - what you learn here will provide a solid foundation.

We cover a lot of material in this series, including these key points:

How to structure content and work with comments

How to evaluate, install and configure modules

How to use views to display lists of content

How to create relationships between content and use them in content lists

How to improve performance and security

How to work with blocks and structure custom block types

How to work with taxonomy, paths, and much, much more

Who this collection is for

This video collection is intended for those who are completely new to Drupal, or for those that want to make sure that they have a solid foundation before moving on to more advanced projects. We assume you know nothing about Drupal, and lead you from start to finish through a practical project.

It looks like there might be an issue playing videos in this browser. We're working on better cross-brower experience, but in the meantime please try the latest Chrome or Firefox browsers. Or, you may be able to watch the video directly without progress tracking or transcript: