metafizzy / isotope

:revolving_hearts: Filter & sort magical layouts
https://isotope.metafizzy.co
11.05k stars 1.41k forks source link

Dynamic Filters (Based on grid-items in the grid) #1249

Closed Suley-Cyplon closed 6 years ago

Suley-Cyplon commented 7 years ago

Hi Guys

I've searched everywhere online and cannot find anything that relates to what I'm trying to achieve. I'm trying to add filters to a group, dynamically using the selectors in my grid.

For example: --- Airlines is the Group of the Filters ------ EasyJet ------ British Airways ------ Monarch ------ Ryanair etc. etc.

But I want to create these Filters only if they are within the Isotope Grid. So, something that can look at the tags (selectors) within the grid-item, and create a new Isotope Filter under the Airlines Group Filter.

Rather than having to create a Filter for every Airlines in the world, and having to hide them all if they have 0 results, which as you can imagine would be near-impossible to manage.

Is there such a thing? Any help or guidance to a similar thread would be much appreciated.

Thanks

Suley

danielsebas commented 6 years ago

I hope I understood you. You should call the filters and grid items from a database: Your MySQLi SQL <?php $rsFilter = new WA_MySQLi_RS("rsFilter",$Database_Connection,0); $rsFilter->setQuery("SELECT SUBSTRING_INDEX( airlines.airline_name, ' ', 1 ) AS airline_first_name, airlines.airline_name FROM airlines"); $rsFilter->execute(); ?>

Your filter:

<ul><li class="active" data-filter="*">All</li> <?php while(!$rsFilter->atEnd()) { ?> <li data-filter=".<?php echo($rsFilter->getColumnVal("airline_first_name")); ?>"><?php echo($rsFilter->getColumnVal("airline_name")); ?></li> <?php $rsFilter->moveNext(); } $rsFilter->moveFirst(); //return RS to first record ?> </ul>