Drupal – $data->field_name problem in Views Custom Field

We have talked about using Views Custom Field which really makes Views more versatile. In the custom PHP field, you can get the data of other fields from $data. But the field names under the $data may changed later as you modify the view.

A workaround is to get the field data from $data using the field_id.

$data->{$this->view->field['field_id']->field_alias}

 

You can get the field_id by mouseover the field name in fields region of Views UI.

Done =)

Reference: field name in $data gets changed after adding new CCK field

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.