0

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

dpm($fields);

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.

1
  • 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 Jun 16 '14 at 1:50
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, privacy policy and cookie policy

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