Hiya,

I am using Views PHP in a drupal 7 multilingual environment and - altho the output is correct and as expected - I am getting the error below:

Notice: Undefined index: de in __lambda_func() (line 5 of views_php/plugins/views/views_php_handler_field.inc(202) : runtime-created function).

I narrowed the problem down to a file-field causing the error. My PHP code to access that field looks something like this (abstracted):

$filepath = $data->_field_data['nid']['entity']->field_file[$data->node_language][0]['uri'];

Any idea how to solve this? Again; I am actually getting the correct value here, yet the error appears.

Thanks in advance!

Comments

partyp’s picture

Same issue I am having. Using this variable in my output code seemed to set it off:
$data->_field_data['nid']['entity']->field_major_road['und'][0]['value']

partyp’s picture

I found out what was going wrong from http://drupal.org/node/1249682 which looks like the same issue. The field value i was trying to print was not filled out for every node which I was printing out in my view. I made sure to set the variable to "" if it was not set.

if(!isset($data->_field_data['nid']['entity']->field_major_road['und'][0]['value'])){
  $data->_field_data['nid']['entity']->field_major_road['und'][0]['value'] = "";
}

Hope that helps!

johnv’s picture

Status: Active » Fixed

Also, since D7.8 an error in field languages was resolved. You can determine if a field is always untranslated ('und' or LANGUAGE_NONE) or is translated ($data->node_language). You can set this on field level with the following:
- install Entity Translation
- go to node type settings, set to 'Enable translation with field translation'
- go to the field, and uncheck 'user may translate this field'.
When ready, set node type settings to 'untranslated' and disable module, if desired.

See also the release nodes of Drupal 7.8 for a conversion script.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

jsi’s picture

<?php
if(!isset($data->_field_data['nid']['entity']->field_major_road['und'][0]['value'])){
  $data->_field_data['nid']['entity']->field_major_road['und'][0]['value'] = "";
}
?>

This removed the error messages. Thanx! Although im not even sure if this is what i need to get what i need. :)
How do i actually get it to print the Node ID?

I am using Ubercart and trying to make the php enter the "nid" (node id), "oid" (attribute id) & "option" (option id), so i can add them to a custom ADD TO CART url.

This is the format it needs:
"cart/add/p[nid]_q1_a[oid]o[option]-i?destination=cart"

How do i get the node id, attribute id & option id from this row in my view to add to cart?
Im using "field collection view" module and it does not have a way to add a product "add to cart" link so i must make it myself via php.

Please help.

johnv’s picture

@jsi,
you better not comment no a closed issue.
To answer your question:
- enable devel module;
- put 'dpm($data->_field_data['nid']);' in your code;
- explore the data.