I have created a view with a "Facet block" with a Search page path set to a search page, and "Hide block" set to "Yes". This block is enabled on every page except the search page.

The expected behavior is that a search is run (with no results displayd), thus enabling the display of Facet API blocks on non search pages.

BUT - There seems to be a race condition between Facet API and the views Facets block from Search API.

facetapi_block_list_alter checks to see if enabled Facet API-blocks has an active search. If it does not, it removes the block. hook_block_list_alter is run before the Facets block (hook_block_view), so there is no search yet and the Facet API blocks are removed..

Atle

Comments

cpliakas’s picture

Hi atlea.

Thanks for posting, and you correctly identified that the race condition is causing the issue. Facet API needs facet data for facet to be displayed, so they query has to have been executed by the time blocks are processed in order to know whether we have data to display. As mentioned at #1417456: Facets on non-search Search API pages broken by facetapi_block_list_alter removing the block, this is a tricky problem to solve. Drupal's block system in general assumes that content is isolated and isn;t able to pull the context of the other blocks being executed.

~Chris

drunken monkey’s picture

Project: Search API » Facet API
Component: Facets » Code

Let's see if we can solve this in Facet API. Otherwise, implementing hook_module_implements_alter() in the Search API Views module might be something to consider (although it would be a rather messy solution).

cpliakas’s picture

Status: Active » Closed (duplicate)

Since this is being punted back to Facet API, closing as a duplicate of #1417456: Facets on non-search Search API pages broken by facetapi_block_list_alter removing the block, which is where most of the discussion is happening.