Since the Documentation for Views 3.0 isn't out yet, does that mean that the way you access field variables is different from Views 2.0? That's because whenever I try the following code (from Views 2.0 docs: http://drupal.org/node/352970), all I get are errors:


    //ERROR message after placing it in views-view.tpl.php:
    Notice: Undefined variable: fields in include() (line 33 of D:\xampp\htdocs\foo\sites\all\themes\foofoo\views\views-view.tpl.php).
    Warning: array_keys() expects parameter 1 to be array, null given in include() (line 33 of D:\xampp\htdocs\foo\sites\all\themes\foofoo\views\views-view.tpl.php).

In my modules I have Devel and Theme Developer enabled so why isnt it working? I also rescan my template files like a boss and clear my cache like a disease but still nothing.

  • If you look at the top of the file you will see the availible variables. $fields is definitive not availible at this level, because it has multiple rows. Jun 11, 2011 at 6:51
  • I got it. It's print $fields['field_productshots']->content;
    – enchance
    Jun 11, 2011 at 13:40

2 Answers 2


Have you tried:

 dsm (array_keys(get_defined_vars())); 

I Drupal 7 $fields variable is undefined in the view template. Use $row:

//for id
//for field_second_side

Current field value is stored in $output.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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