1

l am working on a Drupal 7 site with a custom video block called a leaf. It allows the admin the ability to add Text, Photos and Video. When I add video, it functions properly, but I get the below error.

Strict warning: Only variables should be passed by reference in include() (line 27 of /var/www/vhosts/xxxxxxxxxxx.com/sites/default/themes/custom_theme/templates/views-view-field--leaf-block--nid.tpl.php)

I researched the error and came across similar instances, but the php is a bit over my head.

The code currently reads as:

<?php endif; ?>
<?php 
 $node_to_load = node_load($row->nid);
//line 27 below
 print drupal_render(node_view($node_to_load));
?>

I believe that render needs a reference so as is it is invalid, but I am not sure how to accurately assign the return value or the correct syntax. My attempt is below, but is incorrect.

<?php
$node_to_load = node_load($row->nid);
{
nid++;
}

$reference=$something
node_to_load($reference);
// $something to reference????
?>

Does anyone have any suggestions or advise that would help me? This error doesn’t appear to interrupt the functionality of the videos once added but I would love to clean up the code if possible and understand the situation more.

Thanks,

Dave K
  • 11
  • 2

1 Answers1

0

try this:

<?php 
 $node_to_load = node_load($row->nid);
 $node_view = node_view($node_to_load);
 print drupal_render($node_view);
?>

As you can see in the docs, drupal_render uses a reference.

2pha
  • 9,798
  • 2
  • 29
  • 43
  • Thanks for the reply, but after testing I'm still throwing the same error. For a second I thought it worked because normally the error is displayed on the page the leaf videos are found, but now the same error is displayed on the main page of the site... – Dave K Feb 02 '16 at 21:31
  • If it is the same error then `drupal_render()` has probably been called in another place aswell and needs to be change to code like I posted – 2pha Feb 03 '16 at 05:47