If a user selects a dependent facet, but then deselects the facet on which it was dependent, then the dependent facet information remains in the URL, even though it doesn't seem to do anything.

I did find this comment discussing the matter:

As you both say, it would of course be a really nice to have (but not more) to have such depending facets (who's dependency is not met) removed from the url, too - but this is rather nerd-cosmetics for most use cases, so i'm fine here.

I do need this, though. Any suggestions on where to start on adding this?

Comments

SpaceGoat1701’s picture

I achieved this in my implementation by using the rewrite hook:

/**
 * Implements HOOK_facet_items_alter
 *
 * @param $build
 * @param $settings
 */
function facetapi_dependency_remove_facet_items_alter(&$build, &$settings) {
  if ($settings->facet == "type" && count($build) == 1) {
    $key = key($build);
    if ($build[$key]['#active']) {
      $build[$key]['#path'] = 'explore';
    }
  }
}

Obviously something more portable would be better, but this works for now.

Summit’s picture

Issue summary: View changes

Hi,
Anyone have another option for this please?
May be within the current module?

greetings, Martijn