You are here:  » Descriptions for Feed Filters


Descriptions for Feed Filters

Submitted by ChrisNBC on Wed, 2015-09-09 16:13 in

Hi David,

Hope all is going well.

I wondered if you might be able to help me ...as you know I use a large number of filters to standardise my data feeds. When I look at the filters using the admin screen, it's impossible to tell which filters do what without opening each instance individually. I wondered if you could suggest if there might be a way to allow a description to be added to each filter when it's created which could then be viewed on the filters 'admin' page?

It's a 'nice to have' rather than critical so if it's messy/complex to implement I can put it to one side...

Thanks in advance.

Regards
Chris

Submitted by support on Wed, 2015-09-09 16:29

Hi Chris,

Check out this thread which has versions of this for various distributions but to summarise for 14/06A, if you edit admin/feeds_filters.php first look for the following code at line 130:

    print "<th>".translate("Field")."</th>";

...and REPLACE with:

    print "<th>".translate("Field")."</th>";
    print "<th>".translate("Configuration")."</th>";

And then the following code at line 152:

  print "<td>".$fields[$filter["field"]]."</td>";

...and REPLACE with:

  print "<td>".$fields[$filter["field"]]."</td>";
  print "<td>";
  $data = unserialize($filter["data"]);
  if (is_array($data))
  {
    foreach($data as $k => $v)
    {
      print "<strong>".$k."</strong>: ".$v."<br />";
    }
  }
  print "</td>";

...that will give you a nice field:value output of each filter configuration rather than the serialized version...

Cheers,
David.
--
PriceTapestry.com

Submitted by ChrisNBC on Wed, 2015-09-09 16:54

Hi David,

Wow, that's great! thank you.

Have a good evening.

Best regards
Chris

Submitted by sirmanu on Fri, 2016-10-07 08:03

Is also possible a modify version of this in admin_home where we have columns modified,imported, products and cliks add another column saying if there are any filters? (yes/no)

Submitted by support on Fri, 2016-10-07 08:28

Hi,

Sure - you can add a column showing the number of filters, if you edit admin/index.php and look for the following code at line 29:

    $feeds = array();

...and REPLACE with:

    $numFilters = array();
    $sql = "SELECT filename,COUNT(id) AS numFilters FROM `".$config_databaseTablePrefix."filters` GROUP BY filename";
    if (database_querySelect($sql,$rows))
    {
      foreach($rows as $row)
      {
        $numFilters[$row["filename"]] = $row["numFilters"];
      }
    }
    $feeds = array();

And then look for the following code at line 104:

      print "</tr>";

...and REPLACE with:

      print "<th>".translate("Filters")."</th>";
      print "</tr>";

And finally the following code at line 175:

        print "</tr>";

...and REPLACE with:

        print "<td class='pta_num'>".(isset($numFilters[$filename])?$numFilters[$filename]:"0")."</td>";
        print "</tr>";

As an alternative to the last two changes, you could make the Filters button green if filters exist. To do this instead (or as well as of course) look for the following code at line 152:

  admin_tool("Filters","feeds_filters.php?filename=".urlencode($filename),TRUE,FALSE);

...and REPLACE with:

  admin_tool("Filters","feeds_filters.php?filename=".urlencode($filename),TRUE,isset($numFilters[$filename]));

Cheers,
David.
--
PriceTapestry.com

Submitted by sirmanu on Fri, 2016-10-07 12:39

Excellent!
Regards