Does someone know how to add an "View All" Filter to get all unfiltered Results again?

Comments

adam1’s picture

No I found it my own - it's written in the Isotope Documentation. Just use '*' or '' as data-option-value:
<a href="#filter" data-option-value="*" class="selected">All</a>

rdentry’s picture

How could this be integrated into the view? I have a taxonomy term named "all", which is selected as default for content, but how could I make this with class="selected" on page load?

matt.elkins’s picture

@rdentry I'm not sure if this solution will work for your implementation, but I decided to override the module's views-isotope-filter-block.tpl.php template file in my theme. The template gives you access to the HTML for the filters list, and I've simply added an additional item containing the code snippet from adam1's comment above:

<ul id="filters" class="option-set clearfix" data-option-key="filter">
   // add 'all' filter
   <li><a href="#filter" data-option-value="*" class="selected"><?php print t('All'); ?></a></li>
   
   <?php foreach ( $rows as $id => $row ): ?>
   <?php 
      // remove characters that cause problems with classes
      // this is also do to the isotope elements
      $dataoption = trim(strip_tags(strtolower($row)));
      $dataoption = str_replace(' ', '-', $dataoption);
      $dataoption = str_replace('/', '-', $dataoption);
      $dataoption = str_replace('&amp;', '', $dataoption); 
    ?>
   <li><a class="filterbutton" data-option-value=".<?php print $dataoption; ?>" href="#filter"><?php print trim($row); ?></a></li>
   <?php endforeach; ?>
</ul>

I hope this helps!

eriknewby’s picture

In order to get the views-isotope-filter-block.tpl.php template to work for me I had to update the code from above to:

<div id="isotope-options">
<ul id="filters" class="option-set clearfix" data-option-key="filter">
   <li><a class="filterbutton" href="#filter" data-option-value="*"><?php print t('all'); ?></a></li>
   
   <?php foreach ( $rows as $id => $row ): ?>
   <?php 
      // remove characters that cause problems with classes
      // this is also do to the isotope elements
      $dataoption = trim(strip_tags(strtolower($row)));
      $dataoption = str_replace(' ', '-', $dataoption);
      $dataoption = str_replace('/', '-', $dataoption);
      $dataoption = str_replace('&amp;', '', $dataoption); 
    ?>
   <li><a class="filterbutton" data-option-value=".<?php print $dataoption; ?>" href="#filter"><?php print trim($row); ?></a></li>
   <?php endforeach; ?>
</ul>
</div>

Thanks @matt.elkins!

matt.elkins’s picture

Status: Active » Closed (fixed)

Glad to be of help, @enewby!

rdentry’s picture

Thanks a lot guys. Works great!

wooody’s picture

Thank you , very nice works fine.!

catchmagu’s picture

Thanks matt.elkins!!

That works for me. But how to create a separate class name to each list item???

Thanks in advance!!!

omvaishnav’s picture

How can I disable showing all items on page load.. I need to load only particular filter items.

Can anyone help me..?

Thanks
Om

helonaut’s picture

If I do this:

  1. Navigate to sites/all/modules/views_isotope
  2. Edit the file views-isotope-filter-block.tpl.php
  3. Remove the line discussed in this thread: <li class="first active"><a href="#filter" data-option-value="*" class="selected"><?php print t('All'); ?></a></li>

The link for category "All" is gone, but the filter is still All if you visit the View. How can I make my first custom category the default filter?