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:
<?php print $fields['views_field_field_name']->content; ?>
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.
<div class="<?php print $classes; ?>">
<?php print render($title_prefix); ?>
<?php if ($title): ?>
<?php print $title; ?>
<?php endif; ?>
<?php print render($title_suffix); ?>
<?php if ($exposed): ?>
<div class="view-filters">
<?php print $exposed; ?>
</div>
<?php endif; ?>
<?php print $pager; ?>
<?php if ($header): ?>
<div class="view-header">
<?php print $header; ?>
</div>
<?php endif; ?>
<?php if ($attachment_before): ?>
<div class="attachment attachment-before">
<?php print $attachment_before; ?>
</div>
<?php endif; ?>
<?php print $fields['views_field_field_name']->content; ?>
<?php print $fields['views_field_field_age']->content; ?>
<?php print $fields['views_field_field_phone']->content; ?>
<?php print $pager; ?>
<?php if ($footer): ?>
<div class="view-footer">
<?php print $footer; ?>
</div>
<?php endif; ?>
<?php if ($attachment_after): ?>
<div class="attachment attachment-after">
<?php print $attachment_after; ?>
</div>
<?php endif; ?>
<?php if ($more): ?>
<?php print $more; ?>
<?php endif; ?>
<?php if ($feed_icon): ?>
<div class="feed-icon">
<?php print $feed_icon; ?>
</div>
<?php endif; ?>
</div><?php /* class view */ ?>