[Solved] List of currently active filters

4 years 8 months ago - 4 years 8 months ago #46307 by Michaelw
Hello,

I have several filters on category page. It works perfect.

Is it posible to get at this page some legend with list of active filters?

For exempel - http://www.template-land.com/joomla-templates?filter_41[]=free&filter_42[]=bonusthemes

It is 2 active filters "Type of purchase = Free" and "Provider = BonusThemes"

List of active filters should look like thise:
<h5>2 items found with activ filters:</h5>
<ul>
<li>Type of purchase = Free[x]</li>
<li>Provider = BonusThemes[x]</li>
</ul>
<a ...>Remove all filters



Sorry for my english (my native is russian).


P.S. template-land.com is not my site, but it is good exemple. My site in russian language.

Please Log in or Create an account to join the conversation.

4 years 8 months ago #46323 by ggppdk
Hello

no we do not have an option to print a list of "currently" active filters

if you are a developer, there is a simple solution to get them:
// 1. Get the ACTIVE filter IDs from the PHP  $_GET ARRAY
$active_filter_ids = array();
$varnames = array_keys($_GET);
foreach($varnames as $varname) {
  if (strpos($varname, "filter_") === 0) {
     $varname =  str_replace("filter_", "", $varname);
     $active_filter_ids[] = (int) $varname;
  }
}
 
 
// 2. Just make a map from:  field_ID  -to-  filter DATA
$_filts = array()
foreach($this->filters as $filter) {
  $_filts[$filter->id] = $filter;
}
 
 
// 3. print the filters found to be active
foreach ($active_filter_ids as $active_id) {
  echo "Active Filter:". $_filts[$active_id]->label ."<br/>\n";
}

if i have some syntax error above please correct it,
i have not tested the above

you can place the above e.g. at the top of your FLEXIcontent template file:
category_items.php
or
category_items_html5.php


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

4 years 8 months ago #46378 by Michaelw
Thank you. That's what I was looking for.

Please Log in or Create an account to join the conversation.

4 years 8 months ago #46379 by ggppdk
Hello

you may consider supporting FLEXIcontent project by posting a 5-star review at JED


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
© 2018 Flexicontent. All Rights Reserved.