Code fails only if not logged in Hello I'm currently working in the template.php file to preprocess a view and i'm experiencing strange things:

This relates to a field collection field:

  $collect_field = $value-&gt;field_field_screenshot[0]['rendered']['entity'];


Without being logged in this code fails with 


  Notice: Undefined index: entity


If logged in everything is fine...

Somebody could imagine what is happening here?
As per the error message, no such index 'entity' exists in the array $value-&gt;field_field_screenshot[0]['rendered'] Do a dpm($value-&gt;field_field_screenshot[0]['rendered']) when both logged in and logged out and you will see the difference.

Is field_screenshot associated with a user account or profile? In which case, the anonymous user object has no such field, so you're trying to assign to $collect_field something that doesn't exist. You should assert whether the user is logged in or not before doing the assignment.