I'm getting a strange error on a Views page, even though the page works. I get ten instances of this error:
Notice: Undefined index: field_video in include() (line 28 of
/path/to/drupal/sites/all/themes/mytheme/templates/
views-view-fields--screenings--panel-pane.tpl.php).
Notice: Trying to get property of non-object in include() (line 28 of
/path/to/drupal/sites/all/themes/mytheme/templates/
views-view-fields--screenings--panel-pane.tpl.php).
Here's the content of line 28:
if (preg_match('/media/', $fields['field_video']->content)) {
unset($fields['field_featured_image']);
}
The idea is that if a node of the relevant content type has both a Video and a Featured Image, the view will drop the image and replace it with the video.
What's crazy is that the page renders just fine; the image disappears when the node has content in both fields. What's even crazier is that the error appeared after a minor tweak to the above code, so I reverted my change and it still throws this error, no matter how many times I flush my caches.
What is happening here? This very same code worked fine for a long time, but now I can't seem to get rid of this error!