I'm using the selective filters options in my views and it is REALLY helpful.

Would it be possible to take this a step further and not display the entire exposed filter if there are no terms in the filter?

Thanks.

Comments

Thanks for the request. I've also received another request to disable the filter if there are no terms. So I guess this will be an additional option.

Great!

I'm using Product Attributes exposed filters. It displays all the options within the products in the result set of a particular attribute.

With this functionality I can keep the same taxonomy menu structure and be able to display products with different attributes cleanly. Not sure if that makes any sense, but it'll help me a TON.

Version:6.x-1.0-beta1» 6.x-1.x-dev
Category:support» feature
Status:Active» Fixed

Implemented in the latest dev. Please try t (12 hours from now) and let me know how it works for you.

I've installed the latest dev. I'm not sure that I see any options to add this functionality? Should I see something when editing the exposed filter?

Thanks.

Maybe you downloaded the dev too early, before the new changes were integrated. I checked now and the new code is in. You should find an option "Hide if empty" inside the selective filter options.

I have the option now. When I select it an save I get this error message on my view page.

I'm using product attributes exposed filter.

* user warning: Table 'thepinkg_drp1.content_type_exhausts' doesn't exist query: SELECT DISTINCT(field_manufacture_exhaust_value) FROM content_type_exhausts WHERE nid IN (1018,1017,1016,989,990,973,886,982,981,890,991,983,992,997,1001,861) in /home2/thepinkg/public_html/sites/all/modules/views_hacks/views_filters_selective/views_filters_selective.module on line 168.
* user warning: Table 'thepinkg_drp1.uc_product_options' doesn't exist query: SELECT DISTINCT(oid) FROM uc_product_options WHERE nid IN (1018,1017,1016,989,990,973,886,982,981,890,991,983,992,997,1001,861) in /home2/thepinkg/public_html/sites/all/modules/views_hacks/views_filters_selective/views_filters_selective.module on line 168.
* user warning: Table 'thepinkg_drp1.uc_product_options' doesn't exist query: SELECT DISTINCT(oid) FROM uc_product_options WHERE nid IN (1018,1017,1016,989,990,973,886,982,981,890,991,983,992,997,1001,861) in /home2/thepinkg/public_html/sites/all/modules/views_hacks/views_filters_selective/views_filters_selective.module on line 168.

I'm actually getting these errors just from the update to dev rather than selecting the hide if empty box.

Check the settings again. Perhaps you need to explicitly choose a field to restrict the values? If you've upgraded from an old dev this might very well be the case.

I initally left the restrict field to default. I've changed it to title, I do not get any limiting of the filters. It shows all possible. The errors do go away however.

I also seem to have some illegal choice errors that show an empty view. For this error I only have the limit option set to title and hide unchecked.

In order for the restrict field to work, it needs to exactly correspond to the values in the exposed filter. You can create hidden fields in the view, and select those to restrict the exposed filter values.

So you're saying I should not be able to use a current field that's in the view? I need to have a hidden one for the limiting to work?

The only way I've been able to remove all the errors in the view is to completely turn off limiting.

Would you be able to post a screenshot showing which options I should select to get it to work?

Thanks.

For a field to be used as limiting value for an exposed filter, it needs to contain the same values that go into the exposed filter drop-down. For example, if you want to limit a user drop-down, you need to use a "User: Uid" field and set this as your limiting field. You will probably want to hide this field since the view display should not show it to the end-user.

Does that make more sense?

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Version:6.x-1.x-dev» 6.x-1.0-beta2

I am using views 6.x 3.x
with latest views hacks 6.x-1.0-beta2

and either I don't understand how this is implemented or its not working properly

I have enabled it for a taxonomy term
- Limit "Taxonomy: Term" values to result set
- Further limit values to active filters
- limiting field > default
- Hide if empty

and there are cases that some widgets are empty but still shown

I have also tried with creating a hidden "taxonomy term" of the same kind as the exposed filter
- Limit "Taxonomy: Term" values to result set
- Further limit values to active filters
- limiting field > (the hiden taxonomy field above)
- Hide if empty

but still I can see empty exposed filters
can you give an easy to follow example so that I know I am using it the right way ?

workaround is to modify the views-exposed-form.tpl.php to prevent empty widgets from showing up

<?php if (!empty($q)): ?>
  <?php
   
// This ensures that, if clean URLs are off, the 'q' is added first so that
    // it shows up first in the URL.
   
print $q;
 
?>

<?php endif; ?>
<div class="views-exposed-form">
  <div class="views-exposed-widgets clear-block">
    <?php foreach($widgets as $id => $widget): ?>
      <?php if (!empty($widget->widget)): ?>
      <div class="views-exposed-widget views-widget-<?php print $id ?>">
        <?php if (!empty($widget->label)): ?>
          <label for="<?php print $widget->id; ?>">
            <?php print $widget->label; ?>
          </label>
        <?php endif; ?>
        <?php if (!empty($widget->operator)): ?>
          <div class="views-operator">
            <?php print $widget->operator; ?>
          </div>
        <?php endif; ?>
        <div class="views-widget">
          <?php print $widget->widget; ?>
        </div>
      </div>
      <?php endif; ?>
    <?php endforeach; ?>
    <?php if (!empty($sort_by)): ?>
      <div class="views-exposed-widget">
        <?php print $sort_by; ?>
      </div>
      <div class="views-exposed-widget">
        <?php print $sort_order; ?>
      </div>
    <?php endif; ?>
    <?php if (!empty($items_per_page)): ?>
      <div class="views-exposed-widget">
        <?php print $items_per_page; ?>
      </div>
    <?php endif; ?>
    <?php if (!empty($offset)): ?>
      <div class="views-exposed-widget">
        <?php print $offset; ?>
      </div>
    <?php endif; ?>
    <div class="views-exposed-widget views-submit-button">
      <?php print $button ?>
    </div>
    <?php if (!empty($reset_button)): ?>
      <div class="views-exposed-widget views-reset-button">
        <?php print $reset_button; ?>
      </div>
    <?php endif; ?>
  </div>
</div>

Category:feature» support
Status:Closed (fixed)» Active

its at least a support request

You're doing the right thing AFAICT. There's a condition that triggers the hiding of filters in views_filters_selective.module:

if ((empty($form[$filter_element]['#options']) || array_keys($form[$filter_element]['#options']) === array('All')) && !empty($settings[$filter_id]['vfs_hide_empty'])) {

Can you tell if the code goes inside this block? Use dsm('inside'); inside the block. Otherwise, please find out which condition prevents the code from going inside.

I think I have the same problem.
The 'label' shows up if all terms of that vocabulary are hidden because there are no nodes of that term.

To make myself a bit more clear:
I have a vocabulary lets call it 'colors'.
I have a view that currently shows nodes of which none of them have a color assigned. but there might be a node with a color in the future.
So in that case i don't want to show the label for the vocabulary 'color'.

If i check the checkbox 'Hide if empty' in the exposed filter taxonomy term, the terms lets call them 'yellow, black, white' are hidden but the label 'color' still shows up.

I've installed the latest dev version from 2011-Jul-28 but that did not help either.

Same problem, but I solved it.
When you add exposed filter, It is necessary to leave the default value in Filter identifier. For example: field_product_color_value_many_to_one. If it is cut to color, the label will not be hiding.

I was searching for a very long time this mistake.

Thanks for your reply, but how do i find the default value if I've already changed it?

Version:6.x-1.0-beta2» 7.x-1.0-alpha2

Is this something that is conna be inccluded in the future 7.xx branch?
I desperatly need at solution to this problem.