Preprocessing a front page block causes errors on other pages: why? I'm currently working through self-set tasks to learn Views and pre-processing in Drupal 7. I've created an unformatted view which creates a list of images (which are linked to a content-type but it seems if I replace the fields in view with node:type then I get a link to the node page which is not what I'm after) to place them in a block. I've placed the block into the highlight region and have written a views-view-fields--image.tpl.php file to output the list into various unordered list formats which are then transformed by jCarousel or the featureList jQuery plug-ins. 

On top of this, I've created a page--front.tpl.php file to restyle the front page and it appears to work in that the CSS, js and HTML are working correctly and the carousel and lists appear &amp; work in the defined block. 

However when I leave the front page to another page where the view should not appear, I get the following error:


  Notice: Undefined property: stdClass::$_field_data in iaintest_preprocess_views_view_fields() (line 10 of /Applications/XAMPP/xamppfiles/htdocs/drupal/sites/all/themes/iaintest/template.php).


To pre-process the list that the view outputs, I've written the following pre-process code:

function iaintest_preprocess_views_view_fields (&amp;$variables) {
  if (!$variables['view']-&gt;result[0]-&gt;_field_data) {
    // Line 10 where the error occurs.
  }
  else {
    drupal_add_css(path_to_theme() . '/jcarousel/skins/tango/skin.css');
    drupal_add_css(path_to_theme() . '/featureList.css');
    $js = "
      jQuery.noConflict();
      jQuery(document).ready(function(){
      jQuery('#mycarousel').jcarousel();

      jQuery.featureList(
        jQuery('#tabs li a'),
        jQuery('#output li'), {
          start_item: 1
        }
      );
    });";

    drupal_add_js($js, 'inline');
    $items = array();

    foreach ($variables['view']-&gt;result as $key =&gt; $vars) {
      foreach ($variables['view']-&gt;result[0]-&gt;_field_data['nid']['entity']-&gt;field_images['und'] as $k =&gt; $v) {
        $variables['carousel'][] = array(
          'uri' =&gt; $v['uri'],
          'alt' =&gt; $v['alt'], 
          'title' =&gt; $v['title']
        );
      }
    }
  }
}


I have tried using drupal_is_front_page() or $variable['is_front'] === TRUE to limit this part of the preprocessing to the front page, which is the only place where the original view appears. 

Is this possible at all, or have I misunderstood anything?
Try:

&lt;?php
if (isset($variables['view']-&gt;result[0]-&gt;_field_data)) {
// 
?&gt;


Instead of your weird if/else construct. Not really sure what you are trying to accomplish with that code, so there might be a better way to check if you want to execute it or not.