I would love to have a setting in facetapi_bonus to hide the facet count. Patch attached for review. Updated patch, as settings aren't required.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

cecrs’s picture

cecrs’s picture

jwilson3’s picture

Status: Needs review » Needs work
  1. +++ b/plugins/facetapi/filter_hide_count.inc
    @@ -0,0 +1,49 @@
    +<?php
    +
    +/**
    + * Plugin that removes all items if there are less than X items available.
    + */
    +class FacetapiFilterHideCount extends FacetapiFilter {
    +
    +  // Number of items.
    +  protected $count;
    +  // If there is active item in the list.
    +  protected $active;
    +
    

    I'm not seeing the "Less than X items" functionality here. C&P error from another plugin?

  2. +++ b/plugins/facetapi/filter_hide_count.inc
    @@ -0,0 +1,49 @@
    +  }
    +}
    \ No newline at end of file
    

    Needs a new line

cecrs’s picture

Status: Needs work » Needs review
FileSize
1.91 KB

C+P indeed, thanks for the review!

cecrs’s picture

woprrr’s picture

Its simple with the hook provide with Facetapi_bonus.

For alter all items with callback active (this hook is call once by facet):

function HOOK_facet_items_alter(&$build, &$settings) {
  foreach($build as $key => $item){
    $build[$key]['#count'] = NULL;
  }
}

Or

For alter only my facet 'MYFACETNAME' use $settings.

function HOOK_facet_items_alter(&$build, &$settings) {
if($settings->facet == "MYFACETNAME") {
  foreach($build as $key => $item){
    $build[$key]['#count'] = NULL;
  }
}
}

Or delete the foreach and enter a specific key for alter 1 items particulary

If you need some exemples look : https://www.drupal.org/node/1440016#comment-9530129

woprrr’s picture

Status: Needs review » Closed (works as designed)

@cecrs This issue is closed now ? This hook provide by module Responds to Your Needs ?