How to place facet block in views page header? (not regions) I've created a search with Search API module and Facets module. I've added two taxonomy term name fields to my search index and created two facets for those fields. Just for testing I've placed the facet blocks in my main content area, and fulltext search and faceted filtering are working as expected.

Now I want to place the facet blocks in the header of the view, and not in a page region. I've checked the block source file and ID of the facet blocks is facet_block. Facet blocks are derived blocks, so my best guess was that the block ID should be facet_block:MACHINE_NAME_OF_FACET.

I've added a Global: Rendered entity - Block to the header of the view. As block ID I've entered the schema from above, e.g. facet_block:museum for my "museum" facet.

However, the facet block doesn't show in the views header. (The same facets placed via block layout still work fine.)

Can anybody tell me how to render facet blocks inside a view header?

(I'm looking for a no-code-solution, without preprocessing or editing templates)
Firstly, I would recommend that you consider placing the facet block right above the view instead of performing a surgery on views :D

That said, here's what I think might work:

Solution 1: Views Header


Views allows you to attach rendered blocks in the views header.
In the views UI, click the Add button in the Header configuration.
Then choose Rendered Entity - Block and choose the facets block you want to display


Solution 2: Attachment Before


Write a hook_views_post_build()
In this hook, render the facet block as the attachment_before of the view.


See this answer about rendering blocks programmatically

You might face some difficulties with views caching, etc, but you can fine-tune the views build to alter the caching rules.
If you don't like the idea of Attachment Before, you can also consider adding a header item with a custom token like @facet:foo@ and then replace this custom token with a rendered facet block in hook_views_pre_render()


I hope this helps!