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?


1 Answer 1


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); ?> Commented Mar 23, 2016 at 18:36
  • Is this what you meant to add a function to variable. I created the variable $output Commented Mar 23, 2016 at 18:38
  • yes exactly what I mean. Commented Mar 23, 2016 at 18:41

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