Hi,

FIrst of all, fantastic work on the PHP filter, it's just what I need and I really appreciate your work.

However, I've found a slight issue which is stopping it from working for me at the moment. When I try to use the PHP filter to filter out the results in views, I have the following variables available to me :

$view: The view object.
$handler: The handler object.
$static: A variable that can be used to store reusable data per row.
$row: Contains the retrieved record from the database (e.g. $data->nid).
$row->title: Content: Title
$row->nid: Content: Nid
$row->field_ingredients: Content: Ingredients
$data: Contains the retrieved record from the database (e.g. $data->nid).

They all work fine, apart from my $row->field_ingredients. This is a custom field. I'd be delighted if anyone could suggest a fix for me, as it's a complicated action that just can't be done without using the PHP. I suspect it may be a case of the variable being called something other than $row->field_ingredients, but I'm not a good enough coder to try and work out what this is.

Any help greatly appreciated.

Mark

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

ShadowKyogre’s picture

Could you be a little more specific on what is happening? I get a somewhat similar issue on my test site, except the field value is replaced by the NID of the node. (See attached image)

In the "Scree!" userreference field, it is supposed to print out a 10 next to where "fracks" is, because that is the user id of the test user on there. However, the numbers on the right column correspond with the node id. Turning off the DraggableViews display for this does not fix it. The file you would want to inspect for this is views_php/plugins/views_php_handler_field.inc, in the php_post_execute function. That function is responsible for setting up the variables needed. Particularly, these would lines 135-139 in the file.

        foreach ($this->view->display_handler->get_handlers('field') as $field => $handler) {
			dpm($row);
          $normalized_row->$field = isset($row->{$handler->field_alias}) ? $row->{$handler->field_alias} : NULL;
        }
markduce’s picture

You're absolutely spot on. It is giving the nid of the node involved rather than the custom variable as required.

Did you have any luck in attempting to fix it?

Regards

Mark

ShadowKyogre’s picture

It turns out that the field isn't actually inside the row, even though it does output the field's machine name under the $field variable in the mentioned loop. I took a peek into views/modules/fields/views_handlers_field_field.inc file and the field values there were made in the post_execute() function (line 545 of that file). How we're going to make that data available to the views php field I still don't know yet.

markduce’s picture

I'm afraid that it's a little above me to be able to sort that out. I've just hard coded myself and built a module because I couldn't really see a way to fix it.

Do let me know if you find a way though, would still be useful to me.

zabelc’s picture

I've been seeing something similar, but only in the past couple weeks. It strikes me that something in views has changed perhaps?

I'm trying to get the value of a taxonomy term that's one of my fields (called "field_std_m_txmy_climb_type"). Interestingly if I look in the $row object, the value of that field (field_std_m_txmy_climb_type) is the same as the entity id. If I look in the $data object the field appears as "field_data_field_std_m_txmy_climb_type_node_entity_type" and has a value of the string "node".

cmseasy’s picture

I confirm this issue. I am not a php coder, does anyone have a fix or patch for this, we can test?

oobie11’s picture

Subscribe

timtunbridge’s picture

+1

gabriel.achille’s picture

+1

W.M.’s picture

Subscribe

dean.humphreys’s picture

+1

nelp’s picture

+1

mmilo’s picture

Status: Active » Closed (duplicate)

I ran into this problem too, and there are alot of duplicate issues.

Using #1140896: Variable $row does not contain correct values ($data->_field_data does) as the main one.

andrea.cavattoni’s picture

#13 works fine, use pre and print_r on $data, it helps!