I've made my own version of the Open Atrium News view. It's almost exactly the same - the only difference is that content has to be flagged for the front page - so I made a clone of the Open Atrium News template and added that (giving custom names to both the cloned view and cloned template). However, I would now like to add some fields to the view and am having trouble as I don't know how to add those fields to the template. I would like to add more parent info. I added 'Content: Groups audience' (label: 'Space') and 'Content: OpenAtrium Section' (label: 'Section'), but, as you might expect, they're not being printed because they're not in the template.
Just to refresh your memory, here's the template currently being used:
<?php
/**
* @file
* Default simple view template to all the fields as a row.
*
* - $view: The view in use.
* - $fields: an array of $field objects. Each one contains:
* - $field->content: The output of the field.
* - $field->raw: The raw data for the field, if it exists. This is NOT output safe.
* - $field->class: The safe class id to use.
* - $field->handler: The Views field handler object controlling this field. Do not use
* var_export to dump this object, as it can't handle the recursion.
* - $field->inline: Whether or not the field should be inline.
* - $field->inline_html: either div or span based on the above flag.
* - $field->wrapper_prefix: A complete wrapper containing the inline_html to use.
* - $field->wrapper_suffix: The closing tag for the wrapper.
* - $field->separator: an optional separator that may appear before a field.
* - $field->label: The wrap label text to use.
* - $field->label_html: The full HTML of the label to use including
* configured element type.
* - $row: The raw result object from the query, with all data it fetched.
*
* @ingroup views_templates
*/
?>
<div class='oa-list oa-news clearfix'>
<?php if (!empty($field_user_picture)): ?>
<div class='pull-right'>
<?php print $field_user_picture; ?>
</div>
<?php endif; ?>
<div class='oa-news-header'>
<?php print $title; ?>
<div class='oa-news-posted'>
<?php print t('Posted by ') . $name . t(' on ') . $created; ?>
</div>
</div>
<div class='oa-news-body'>
<?php if (!empty($field_oa_media)): ?>
<div class='oa-news-image pull-left'>
<?php print $field_oa_media; ?>
</div>
<?php elseif (!empty($field_featured_image)): ?>
<div class='oa-news-image pull-left'>
<?php print $field_featured_image; ?>
</div>
<?php endif; ?>
<?php if (!empty($body)): ?>
<div class='oa-news-body'>
<?php print $body; ?>
</div>
<?php endif; ?>
<?php if (!empty($term_node_tid)): ?>
<div class='oa-news-tags'>
<?php print t('Categories: ') . $term_node_tid; ?>
</div>
<?php endif; ?>
</div>
</div>
What do I need to add to get these two new fields to load correctly? There is the chance that I'm just adding the wrong fields, so I do apologise if it's my own error, but I did add some text to display if there were no results and that also didn't appear.
Comments
Comment #1
kdmcguire commentedFixed, thanks to /u/bodyelectrik on /r/drupal's beginner questions thread. Added code (below) between body and category to template.