Well i can't access all the elements in the object: $data. The weird thing is that in the output field i can access all the elements, but not in the filter and value fields.
This works in the output field :
$data->field_field_image['0']['rendered']['#item']['filename'];
But it doesn't work when used in the value or filter field. I tried to put :
return $data->field_field_image['0']['rendered']['#item']['filename'];
and then in the output field
print_r ($value);
but it does not give me the value. Looking at the data object i can acces files down to 'views_php_3' where after i cannot access anything. Maybe it is because of the object in views_php_3, that doesn't exist, when outputting $data directly from the output field.
Data object as printet from the value field :
stdClass Object
(
[node_title] => Some title
[nid] => 42
[field_data_field_event_date_field_event_date_value] => 2012-08-04 11:00:00
[field_data_field_event_date_node_entity_type] => node
[field_data_field_image_node_entity_type] => node
[views_php_3] => stdClass Object
*RECURSION*
[_field_data] => Array
(
[nid] => Array
(
[entity_type] => node
(... lots and lots of elements, and then... )
[field_field_image] => Array
(
[0] => Array
(
[rendered] => Array
(
[#theme] => image_formatter
[#item] => Array
(
[fid] => 39
[alt] =>
[title] =>
[width] => 480
[height] => 178
[uid] => 1
[filename] => 320481_413513812033006_93978818_n.jpg
[uri] => public://320481_413513812033006_93978818_n.jpg
[filemime] => image/jpeg
[filesize] => 13951
[status] => 1
(and then many more.. )
Comments
Comment #1
shympek CreditAttribution: shympek commentedTry something like that in filter field
Comment #2
zaclittleberry CreditAttribution: zaclittleberry commentedThis topic needs bumped up a lot more. Until a fix is found, Filter is unusable with field references except for with titles.
shimpek's suggestion didn't work for me. It didn't lead to a correct return in filter and in output as a global: php field when printing it didn't display anything.
If it worked for anyone, or if anyone has an alternate fix for this, I (and I'm sure a lot of other people) would be interested in hearing it.
Comment #3
zaclittleberry CreditAttribution: zaclittleberry commentedI found a fix to using custom field references in the filter module! I modified shympex's code. Since it seems that the $data variable is not usable in the global: php filter, I took advantage of row->field_xx giving us the nid.
note: it also seems to only have one occurrence of 'field' in the field reference (see below).
OLD CODE:
WORKING CODE FOR GLOBAL PHP FILTER:
If anyone has comments or questions I would love to hear them. I hope this works for others as well.
Comment #4
nhck CreditAttribution: nhck commentedI encountered this problem as well and added an nid field.
I solved it like this:
For the output field I then postprocess
Performance-wise this is probably horrible - thus bumping it to major.
Comment #4.0
nhck CreditAttribution: nhck commentedAdded some code to demostrate.
Comment #5
boromino CreditAttribution: boromino at LakeDrops commentedhttps://www.drupal.org/project/views_php/issues/1088776 fixes the issue.
Comment #6
boromino CreditAttribution: boromino at LakeDrops commentedComment #7
Liam Morland