I have to hide the Drupal facet API block if it has only one item. Is there any settings available or should I go with any hooks?

2 Answers 2


Use the module facetapi_bonus and you will get an option to hide a facet if the view has only X item(s)

This setting can be accessed through 'facets > configure filters'


I tried this and it works for me.

function MYCUSTOMMODULE_block_view_alter(&$data, $block) {

if($block -> module == 'facetapi' && !empty($data)){        
    $key = $data['content']['#contextual_links']['facetapi'][1][2];
    $count = count($data['content'][$key]['#items']);
    if($count <= 1){


This is a generic one where it affects for all facets blocks site wide which I need.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.