1

I'm trying to use Views PHP filter feature to remove rows which don't contain some data (I can't just use "Hide if empty" feature, because the module returns a string even if there is no real value.

I'm using this string for a filter, however, if doesn't work - instead of filtering, view returns all values.

return isset($data->_field_data['nid']['entity']->field_poloha_obce_pol[und][0][geometry]);

I tried to inspire myself from some of the similar issues here, but it seems to me, that everything should be correct.

I also tested this exact code as PHP field and it returns expected value.

4
  • Is the [und] and [geometry] really written exactly like that? Commented Apr 15, 2014 at 15:58
  • what is type of this field? where you put this code in php views filter (setup? value? return?)
    – Yuseferi
    Commented Apr 15, 2014 at 15:58
  • @kari-kaariainen Yes, I copied those keys from PHP field, where it returned expected value. I determined correct values by using print_r function on $data variable. Commented Apr 16, 2014 at 6:17
  • @zhilevan The filed is of type Postgis. I put that code into "Filter code" textarea. I can post screenshot if needed. Commented Apr 16, 2014 at 6:20

1 Answer 1

1

Try

 return empty($data->_field_data['nid']['entity']->field_poloha_obce_pol['und'][0]);
5
  • I tried it, but it is probably true for all results, as it removes all of them. Commented Apr 16, 2014 at 9:24
  • not, if this field not empty it return false and then it will be show
    – Yuseferi
    Commented Apr 16, 2014 at 11:01
  • Yes, I understand, that it should work in theory, but in reality, it does not. Commented Apr 16, 2014 at 12:01
  • try dpm(empty($data->_field_data['nid']['entity']->field_poloha_obce_pol['und'][0])); and wrote me what it return to you
    – Yuseferi
    Commented Apr 16, 2014 at 15:09
  • Sorry, I don't have time right now,thanks for help. Commented Apr 18, 2014 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.