This question already has an answer here:

In Drupal 7. I am printing a cck field image to my page.tpl like this

<?php print render(field_view_field('node', $node, 'field_slide_photo1', 
array('label'=>'hidden'))); ?>

and I get this error php Strict warning: Only variables should be passed by reference in include() (line 59 of var/www/html/upgrade2a/sites/all/themes/themea/page.tpl.php

But I can use this in node.tp with out errors? print render($content['field_upload_thumbnail']);

How do a print a field that is available in the page template?

marked as duplicate by Clive theming Mar 23 '16 at 18:42

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.


You should attrubute the result of function to variable and then pass to render. The difference is that in sencond case you're passing certain variable instead of result of function.

  • 4
    Ithe error went away when I did this- <?php $output = field_view_field('node', $node, 'field_slide_photo1'); print render($output); ?> – paulcap1 Mar 23 '16 at 18:36
  • Is this what you meant to add a function to variable. I created the variable $output – paulcap1 Mar 23 '16 at 18:38
  • yes exactly what I mean. – Tigran Vardanyan Mar 23 '16 at 18:41

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