0

In template_preprocess_views_view_fields(&$variables), when I print $variables['row'], I get the following object.

enter image description here

How can I access values inside the node entity?

I tried with the following code, but it is not working.

$variables['row']->_entity->values['field_file_pdf_upload']->target_id
1

values is protected, so you have to use the get() method:

$variables['row']->_entity->get('field_file_pdf_upload')->target_id;

For the field object this shortcut is available (this is not standard OOP and works for fields only):

$variables['row']->_entity->field_file_pdf_upload->target_id;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.