3

I would like to print the result when calling the node_load() function. All I get is an error... How do I get something on my screen?

Here is the code I try:

$form = node_load(1473);
print render($form);

And the error:

Recoverable fatal error: Object of class stdClass could not be converted to string in include() (line 10 of ... 

How can I display the content of $form properly?

2 Answers 2

18

You should use the node_view() function to prepare the correct output for your required view mode:

$view_mode = 'teaser'; // Or 'full' for example

$node = node_load(1473);

$view = node_view($node, $view_mode);

print render($view);
0

I think you are trying to get the array structure of a node you can dot it with the help of below code.

<?php echo "<pre>"; print_r(node_load(1473)); echo "</pre>"; ?>
1
  • 1
    Or dpm(node_load(1473)) if you are using devel.
    – Felix Eve
    Commented Mar 21, 2014 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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