Print views fields in a custom view page template I am trying to create a custom view page template which will be made of custom fields, which i am trying to print. I created a view page and added all the needed fields to it.

Next, I created a views-view--my-page-name.tpl.php template, which get's recognised, however when i try to print the fields, i get the errors below:

Notice: Undefined variable: fields in include...

Notice: Trying to get property of non-object in include....

Below is the full code of my custom view page template which i copied from the default view page template and modified it. Im trying to print the field with this code:

&lt;?php print $fields['views_field_field_name']-&gt;content; ?&gt;


I tried all variables of field name as: field_name, field_field_name, views_field_field_name, but none of them work, as they all give same error.

&lt;div class="&lt;?php print $classes; ?&gt;"&gt;
  &lt;?php print render($title_prefix); ?&gt;
  &lt;?php if ($title): ?&gt;
    &lt;?php print $title; ?&gt;
  &lt;?php endif; ?&gt;
  &lt;?php print render($title_suffix); ?&gt;


  &lt;?php if ($exposed): ?&gt;
    &lt;div class="view-filters"&gt;
      &lt;?php print $exposed; ?&gt;
    &lt;/div&gt;
  &lt;?php endif; ?&gt;

  &lt;?php print $pager; ?&gt;

  &lt;?php if ($header): ?&gt;
    &lt;div class="view-header"&gt;
      &lt;?php print $header; ?&gt;
    &lt;/div&gt;
  &lt;?php endif; ?&gt;

  &lt;?php if ($attachment_before): ?&gt;
    &lt;div class="attachment attachment-before"&gt;
      &lt;?php print $attachment_before; ?&gt;
    &lt;/div&gt;
  &lt;?php endif; ?&gt;


&lt;?php print $fields['views_field_field_name']-&gt;content; ?&gt;
&lt;?php print $fields['views_field_field_age']-&gt;content; ?&gt;
&lt;?php print $fields['views_field_field_phone']-&gt;content; ?&gt;


  &lt;?php print $pager; ?&gt;


  &lt;?php if ($footer): ?&gt;
    &lt;div class="view-footer"&gt;
      &lt;?php print $footer; ?&gt;
    &lt;/div&gt;
  &lt;?php endif; ?&gt;

  &lt;?php if ($attachment_after): ?&gt;
    &lt;div class="attachment attachment-after"&gt;
      &lt;?php print $attachment_after; ?&gt;
    &lt;/div&gt;
  &lt;?php endif; ?&gt;

  &lt;?php if ($more): ?&gt;
    &lt;?php print $more; ?&gt;
  &lt;?php endif; ?&gt;  

  &lt;?php if ($feed_icon): ?&gt;
    &lt;div class="feed-icon"&gt;
      &lt;?php print $feed_icon; ?&gt;
    &lt;/div&gt;
  &lt;?php endif; ?&gt;

&lt;/div&gt;&lt;?php /* class view */ ?&gt;
You are using template for display, here you will do theming for overall display, the $fields variable is not available here. 

If you want to change how fields are printed relative to each other, row style, then you should use views-view-fields.tpl.php, in your case the name will be like views-view-fields--yourpagename.tpl.php.

but if you want to theme individual fields then you have to use views-view-field--yourfieldname.tpl.php.