You are here:  » Display extra field in filters page


Display extra field in filters page

Submitted by pricetapid on Sat, 2010-04-10 15:27 in

Hi,

I would like to display the actual criteria on the filters page.

Right now, it display 3 or 4 columns (Search and Replace, Configure Delete, Field) depending on how you count it.

I would like to display the criteria at the end of each row. I can tell it's probably on the feeds_filters.php page, but, how can I do that?

Thanks.

Submitted by support on Sat, 2010-04-10 16:17

Hi,

Yes - that can be done quite easily. In admin/feeds_filters.php, look for the following code at line 80:

 print "<th>Field</th>";

...and REPLACE with:

 print "<th>Field</th>";
 print "<th>Criteria</th>";

And then look for the following code at line 98

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

...and REPLACE with:

     print "<td>".$fields[$filter["field"]]."</td>";
     print "<td>".print_r(unserialize($filter["data"]),TRUE)."</td>";

Hope this helps!

Cheers,
David.

Submitted by pricetapid on Sun, 2010-04-11 17:31

Hi David,

Thanks David.

Submitted by support on Sun, 2010-04-11 17:48

Hi,

That was the plan...! This line:

print "<td>".unserialize($filter["data"])."</td>";

...should actually be:

print "<td>".print_r(unserialize($filter["data"]),TRUE)."</td>";

The output may appear a little cryptic but you should be able to pick-out all the relevant information without needing special code to display the settings for each filter type.

Cheers,
David.

Submitted by pricetapid on Sun, 2010-04-11 18:07

Okay, thanks. I thought I would re-try explaining it just in case we weren't thinking the same thing. Anyways, I understand the output.

For some reason it doesn't display inside the table cell, but, that's alright, it displays what I need to know.

Submitted by support on Sat, 2012-08-04 08:19

To make the same modification for Global Filters, look for the following code at line 69 of admin/global_filters.php

    print "<th>Field</th>";

...and REPLACE with:

    print "<th>Field</th>";
    print "<th>Criteria</th>";

...and then look for the following code at line 87:

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

...and REPLACE with:

     print "<td>".$config_fieldSet[$filter["field"]]."</td>";
     print "<td>".print_r(unserialize($filter["data"]),TRUE)."</td>";

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Sun, 2012-08-05 11:21

Thanks David;

That will work for me.

Submitted by gregor on Fri, 2012-08-10 01:43

This is a good mod. Thanks.

I use HTML in my filters so I added htmlspecialchars to make the html display as text instead of being interpreted. Here's the code. Please let me know if you see any issues.

print "<td>".htmlspecialchars(print_r(unserialize($filter["data"]),TRUE))."</td>";

Thanks,
Gregor

Submitted by support on Fri, 2012-08-10 07:18

That looks fine, Gregor!

Cheers,
David.
--
PriceTapestry.com

Submitted by affiliben on Fri, 2013-05-17 12:20

Hi David,
I use this mod and it works well and is really useful. Is there a way to display the category mapping with a list of alternates in a similar way in the admin panel, so you can easily see the alternatives. Obviously it might be too much for larger sites but where there are just a few category mappings it could save overlaps.
I have tried the following on categories.php in a similar place to the filters.php, but it does not work

print "<td>".print_r(unserialize($category["alternates"]),TRUE)."</td>";

Also with the shortlist feature http://www.pricetapestry.com/node/3707 is there a simple way to email the results to the user or make the cookie longer than the one session.
Many Thanks
Ben

Submitted by support on Fri, 2013-05-17 14:16

Hi Ben,

The `alternates` field is actually stored as a new-line separated string, so have a go with just:

print "<td>".print nl2br($category["alternates"])."</td>";

Regarding the shortlist - sure the cookies can be made persistant (by setting an expire date way into the future). In the shoppingList.php script there are 2 instances of the line that sets the cookie:

    setcookie("shoppingList",serialize($shoppingList));

...REPLACE each with:

    setcookie("shoppingList",serialize($shoppingList),mktime(0,0,0,1,1,2035));

Cheers,
David.
--
PriceTapestry.com

Submitted by affiliben on Fri, 2013-05-17 15:02

Hi David
They both work brilliantly. Fantastic Help as Always
Thank you very much
Ben
Ps The first set cookie line of your reply to be replaced should have been
setcookie("shoppingList",serialize($shoppingList));

Submitted by support on Fri, 2013-05-17 15:06

Ah yes, well spotted! (corrected above)

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Thu, 2015-07-23 22:31

Bob L.

Hi David,

Ran into a problem with this mod that I use on previous versions.

version 15/09 Beta

I've tried this
print "<td>".$fields[$filter["data"]]."</td>";
& this.
print "<td>".print_r(unserialize($filter["data"]),TRUE)."</td>";

But neither returns any output.

Thanks in advace.

Submitted by support on Fri, 2015-07-24 07:48

Hello Bob,

The second version;

print "<td>".print_r(unserialize($filter["data"]),TRUE)."</td>";

...should work fine in 15/09A (Beta) however for a more user-friendly output, have a go with the following modification to admin/feeds_filters.php. Look for the following code at line 149:

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

...and REPLACE with:

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

If still nothing showing let me know and I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Fri, 2015-07-24 10:43

Bob L.

You be the man, Mr. David.

Your version worked like a Champ.

Thank you.

Submitted by BobL on Sat, 2015-07-25 20:41

Bob L.

I really like the output of this mod David.
Might be a quick fix ???
These 6 Filters return an error code on line# foreach as there isn't any data required for them.

Name Case
UTF8 Encode
UTF8 Decode
HTMLEntityDecode
Trim Spaces
Remove Duplicates

Thanks in advance.
Bob L.

Submitted by support on Sun, 2015-07-26 08:59

Hello Bob,

No problem, alternative replacement:

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

Cheers,
David.
--
PriceTapestry.com

Submitted by BobL on Sun, 2015-07-26 12:14

Bob L.

Thank you David.