Checklist filter issue

35 views
Skip to first unread message

hvalentim

unread,
May 21, 2012, 12:09:06 PM5/21/12
to PorPOISe
Hi!

I am having a really hard time figuring out how to get a checklist
filter working with 1.2beta2.

I assume "type" is currently actually stored in the database table as
"icon_type", right?

But whenever an item is checked I always get "errorString": "No POIs
found. Increase range or adjust filters to see POIs".

Any help would be much appreciated. Thanks!

This is my what I have in mypoiconnector.class.php:

<?php
class MyPOIConnector extends SQLPOIConnector {
public function passesFilter(POI $poi, Filter $filter = NULL) {
if (empty($filter->checkboxlist)) {
/* no boxes checked, type doesn't matter */
return TRUE;
} else {
if (in_array($poi->type, $filter->checkboxlist)) {
return TRUE;
}
}

/* no filter matched */
return FALSE;
}
}

hvalentim

unread,
May 22, 2012, 9:07:22 PM5/22/12
to PorPOISe
Actually
if (in_array($poi->type, $filter->checkboxlist)) {
should be:
if (in_array($poi->icon->type, $filter->checkboxlist)) {

This works:
<?php

class MyPOIConnector extends SQLPOIConnector {

public function passesFilter(POI $poi, Filter $filter = NULL)
{
/*
* Always return TRUE if no filter is given
*/

if (empty($filter->checkboxlist)) {
/* no boxes checked, type doesn't matter */
return TRUE;
} else {
if (in_array($poi->icon->type, $filter->checkboxlist)) {
return TRUE;
}
}

return FALSE;

icanscream

unread,
Jun 7, 2012, 9:27:29 PM6/7/12
to PorPOISe
Hi!
I tryed your code but it doesn´t seem to be working to me....i read
somewhere that maybe the data type array it´s the problem...Any ideas?
Does the code work for everyone else?
Thanks in advance!
Message has been deleted

hvalentim

unread,
Jun 8, 2012, 6:56:05 AM6/8/12
to porp...@googlegroups.com
I paste bellow the code I have currently working (1.2 beta2). Not exactly what I wanted too but it is the best I could figure.

It applies both filters independently and in a cumulative way, delivering both the results with keyword X AND OR anything within the categories checked.

Implying also that to return just the results with keyword "X" no categories should be checked by the user.

BTW, the "Always return TRUE if no filter is given" part given in the documentation <http://code.google.com/p/porpoise/wiki/Filters> no longer seems to work. Using that code, if nothing is given in the filters nothing is returned. Alternatively, one can get around it by specifying the layer to have all categories check by default.

I do hope someone more knowledgeable can shed some light here.


<?php

class MyPOIConnector extends SQLPOIConnector {

public function passesFilter(POI $poi, Filter $filter = NULL) {

if (in_array($poi->icon->type, $filter->checkboxlist)) {
return TRUE;
}
if (stripos($poi->text->title, $filter->searchbox1) !== FALSE) {
return TRUE;
}
if (stripos($poi->text->description, $filter->searchbox1) !== FALSE) {
return TRUE;
}
if (stripos($poi->text->footnote, $filter->searchbox1) !== FALSE) {
return TRUE;
}
return FALSE;
Reply all
Reply to author
Forward
0 new messages