I wonder if there is a way to have collapsible grouping (or at least normal grouping) in exposed filters, like in CCK module. Ιf you have many filters in a view, this feature would be useful.

I am not sure if current version of views supports this, that's why i tagged it as a support request.

Comments

dawehner’s picture

The exposed forms are pluggable, so it would be able to write a plugin which makes this possible.
This plugin can live in contrib somewhere else, so views keeps clean.

dagmar1 wrote already some stuff with exposed form plugin.

esmerel’s picture

Status: Active » Fixed
sotiris’s picture

Status: Fixed » Active

Do we have some new plugin and we changed the status?

dagmar’s picture

Status: Active » Fixed

You can wrap all the views-exposed-form.tpl.php template into a collapsible fieldset using this template: more info here: http://drupal.org/node/118343#comment-1442786

<?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; ?>

<?php
drupal_add_js('misc/collapse.js');
?>

<fieldset class = "collapsible">
  <legend class="collapse">
    <a href="#">Views Filters</a>
  </legend>
  <div class="fieldset-wrapper">
    <div class="views-exposed-form">
      <div class="views-exposed-widgets clear-block">
        <?php foreach($widgets as $id => $widget): ?>
          <div class="views-exposed-widget">
            <?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 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; ?>
        <?php if (!empty($reset_button)): ?>
          <div class="views-exposed-widget">
            <?php print $reset_button; ?>
          </div>
        <?php endif; ?>
        <div class="views-exposed-widget">
          <?php print $button ?>
        </div>
      </div>
    </div>
  </div>
</fieldset>
merlinofchaos’s picture

Sorry, a support request does not indicate that we will create a new plugin for your use case. If we tell you how to accomplish something in a support request, it can be mark fixed. Given the number of possible plugins that are out there, you may rest assured that the vast majority of minor use cases will not have new plugins created for Views that will ship with it.

The whole reason Views is pluggable is so that when Views doesn't do something you need it to do, but it is possible with a plugin, you can write the plugin for your purposes. You can use it just on your site or release it as a module.

sotiris’s picture

Dagmar thank you for your help!
@Merlin I thought that something can be marked as fixed only when we have some solution that actually works (in our situation some plugin). But as you said we can consider something fixed if we have the ability to build it, thanks for clarifying this.

Status: Fixed » Closed (fixed)

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

MaxPalpatin’s picture

I can't open the page http://drupal.org/node/118343#comment-1442786
"Access denied
You are not authorized to access this page."

Should I be the member of some group or else?

SeanA’s picture

Also can be put in views-view.tpl.php:

<?php if ($exposed): ?>
    <?php
      drupal_add_js('misc/collapse.js', 'core');
    ?>
    <fieldset class="collapsible collapsed">
      <legend class="collapse">
        <a href="#">Exposed filters</a>
      </legend>
      <div class="view-filters fieldset-wrapper">
        <?php print $exposed; ?>
      </div>
    </fieldset>
  <?php endif; ?>
mike27’s picture

For anyone who's interested, if you want to implement this in drupal 7 here is a working example:

<?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; ?>

<?php 
drupal_add_library('system', 'drupal.collapse');
drupal_add_js('misc/collapse.js');
?> 
  <fieldset id="fieldset-id"  class = "collapsible">
  <legend> <span class="fieldset-legend"> sadfasdf</span>
     
  </legend>
  <div class="fieldset-wrapper">
  <div class="fieldset-description">Fieldset description</div>
    <div class="views-exposed-form">
      <div class="views-exposed-widgets clear-block">
        <?php foreach($widgets as $id => $widget): ?>
          <div class="views-exposed-widget">
            <?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 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; ?>
        <?php if (!empty($reset_button)): ?>
          <div class="views-exposed-widget">
            <?php print $reset_button; ?>
          </div>
        <?php endif; ?>
        <div class="views-exposed-widget">
          <?php print $button ?>
        </div>
      </div>
    </div>
  </div>
</fieldset> 
mrweiner’s picture

Thanks for the D7 version, but does anybody know how to go about keeping the default classes available for each exposed filter? It's great having the fieldset, but not being able to move each filter around individually isn't exactly optimal.

brandy.brown’s picture

So #11 worked great for me. However, does anyone know how to make the fieldset collapsed by default?

brandy.brown’s picture

mrweiner’s picture

Version: 6.x-3.0-alpha2 » 7.x-3.3

You should be able to just add "collapsed" into the fieldset class beside "collapsible."

brandy.brown’s picture

perfect. thanks!

malancheril’s picture

This almost works for me. The text in the legend doesn't do anything when clicked. Adding the class "collapsed" will collapse my exposed filters but clicking on the legend doesn't open or close it. Any ideas?

*Update* Turned off the Superfish module and it worked. Any ideas what could be causing that?

finex’s picture

There is one problem with the suggested solution for D7: if you add the "collapsed" class, when the page reload the filter is collapsed, but when at least a filter is selected it should be better to display the exposed filters (from a usability point of view).

A solution would be to conditionally add the "collapsed" class counting the number of $_GET parameters:

<fieldset class=" collapsible <?php print (count($_GET) == 1) ? 'collapsed' : ''; ?>">

I hope it will be useful.