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 :

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
    [_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.. ) 



shympek’s picture

Try something like that in filter field

$node = node_load($data->nid);
$value = $node->field_field_image['0']['rendered']['#item']['filename'];
zacdavidm’s picture

This 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.

zacdavidm’s picture

I 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).




$node=node_load($nid = $row->field_image, $vid = NULL, $reset = FALSE);
$data=$node->field_image['und']['0']['rendered']['#item']['filename']; //your path might be different. I tried to match it up. do a print_r($data); in a global:php output field to find your path.

If anyone has comments or questions I would love to hear them. I hope this works for others as well.

nhck’s picture

Priority: Normal » Major

I encountered this problem as well and added an nid field.
I solved it like this:

//VALUE Field
$node= node_load($data->nid);
$collection = field_get_items('node', $node, 'field_authors');
return $collection; //this will come out as $value in the OUTPUT field

For the output field I then postprocess

//OUTPUT Field
foreach($value as $item) {
echo $item;

Performance-wise this is probably horrible - thus bumping it to major.

nhck’s picture

Issue summary: View changes

Added some code to demostrate.