I'm attempting to create a custom template for a view. The template file I'm creating is being loaded (if I add some static html it renders).

I'm having trouble accessing values from the view. The tutorial I'm using advises using


To output the available fields. This is coming up as an undefined variable.

Googling suggests using $rows instead of fields but this was also undefined in this case.

  • 3
    what is the file name of the template you started with - ie: are you working with views-view.tpl.php, views-view-field.tpl.php, etc.
    – Geoff
    Commented Jun 16, 2014 at 1:50

1 Answer 1


The $fields variable will be available for theming only if you have selected to display fields instead of content, check under format section of view.

Secondly, the $fields variable is not available if your template file is views-view.tpl.php, you have to use views-view-field.tpl.php or if you want theme only a specific field, you can use views-view-field--fieldname.tpl. php.

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.