Search API Views - How to display facets on a views block? I am using Search Api Views and Facet API to achieve that.

I am trying to enable facets to a views block, or when calling a view programmatically, but unfortunately they are not displayed as expected.

However facets are correctly displayed on the page created under views interface:



I tried to create a block via views interface, and then adding it through blocks, but the facets block doesn't appear. 

Either if a try to print the view programmatically this way:

$view = views_get_view('news_search_api_');
$view-&gt;set_display('page');
$preview = $view-&gt;preview('page');
print $preview;


The facets are not loaded at all.
The answer depends on your theme; but this is an example of how to do it with 'Commons' 

in > admin > Structure > Blocks


  Search for your facets and select the block you want them to go in .  ie 'Sidebar First' 
  
  SAVE 
  
  open your View > Page .
  
  under FORMAT change Show to 'Panel Fields' 
  
  In Settings choose your Panel Layout from the list.  ie 'AT One Column' should display the above block example. 





  And then still in the VIEW - making sure you are in the 'Page' display; otherwise you won't see this option.  Under 'Advanced' - you should now see under 'Exposed Form' the text 'Exposed form in block:'  - Change this to Yes. 
  
  once you've added this to the view you'll now be able to 
  go back to > structure > blocks.
  And see the exposed form here to move to the block you wish. 


This information should be enough to point you in the right direction.