Search code examples
drupaldrupal-6

How to change the default value (-Any-) of an exposed filter in Drupal Views, when using Hierarchical Select?


I've made a view with an exposed filter. This filter is taxonomy based, and I'm using Hierarchical Select as the widget because this taxonomy is deeply nested.

This question is greatly similar to: How to change the label of the default value (-Any-) of an exposed filter in Drupal Views?

However, the poster of that question was not using HS, and so I cannot use the answers there, specifically this one: https://stackoverflow.com/a/5975294/443219

Where exactly should I place the '#options' key in the $form array when using hook_form_alter, to make this work? I've tried pasting the relevant line of code blindly in different places throughout the array, but I believe HS works a tad different to FAPI...


Solution

  • I have a horrible answer to this.

    I changed line 402 in sites/all/modules/hierarchical_select/hs_taxonomy_views.module from:

    $any_label = variable_get('views_exposed_filter_any_label', 'old_any') === 'old_any' ? '<'. t('Any') .'>' : '- '. t('Any') .' -';
    

    to

    $any_label = variable_get('views_exposed_filter_any_label', 'old_any') === 'old_any' ? 'Worldwide' : '- '. t('Any') .' -';
    

    This works because: in this site, I need the filter on only view - and nowhere else.

    This can never be a general solution because:

    1. The unholy sin of hacking the core of a module will haunt me forever because I cannot ever use drush to update this module again.
    2. If I ever make another view in this site, and decide to have a hs taxonomy exposed filter, it's "Any" option will be displayed as "Worldwide", even if there is no such context: weird.

    I would greatly appreciate if anyone can point me in a direction that will allow me to solve this cleanly. But I'm going with my hack for now.