0

Unsupported operand types in /node/node.module on line 1419

On my site users have the ability to flag a content type (node) as being featured on the right rail. I then have a view that renders a view mode called card_view of that specific node. This works great but if you attempt to render that card_view view mode on the same page as the full content view mode you get an error above. Debugging the error occurs when rendering the full content and not the card_view. This also occurs when attempting to render it programmatically:

// Error occurs here (snippet from node.module line 1419)
  $node->content += field_attach_view('node', $node, $view_mode, $langcode);

// Error occurs viewing full content and attempting to render same node in a different view mode
$node = node_load($nid);
$node_view = node_view($node, $view_mode = 'card_view', $langcode = NULL);
echo drupal_render($node_view);

If I remove the attempt to render this node in this view mode it works fine, and also if I attempt to render a separate node it works fine as well, it ONLY occurs when rendering the node view mode on that same node full content page.

0

I found the solution but do not know the actual cause. Apparently I have to clone the current node to avoid conflicts:

$node = clone menu_get_object();
$node_view = node_view($node, $view_mode = 'card_view', $langcode = NULL);
echo drupal_render($node_view);

If anyone has any detail feel free to edit or add a comment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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