I've created a block and put some php in it to display the body of a node using the code form here: http://drupal.org/node/300910#comment-4183142

//get the ID from the URL
$node_id = basename($_SERVER['REQUEST_URI']);
echo $node_id;
//Load the node object.
$node = node_load($node_id);
//Get the node array into memory.
//Now you can parse only the body value into a variable.
$node_content = $node->content['body']['#value'];
//Printing content.
echo $node_content;

The page I've tried this on prints the ID in the block (as expected) but not the body of the node with that ID.

My hunch is that $node_content = $node->content['body']['#value']; can't be used in a block.

Any thoughts? Thanks!

2 Answers 2


I found out how to do this:

$node_id = basename($_SERVER['REQUEST_URI']);
$node = node_load($node_id);
echo $node->body['und'][0]['value']

I have also found out that there is probably a better way to do this using field_view_value(), but I am not quite sure how that works.


Why are you calling node_view here if not using the output.
It is better to do as under...

$node_content = node_view($node);
echo $node_content;

This should work!

  • Thanks for you reply, unfortunatley this didn't work, what I'm trying to do is only return the body of the node. What you suggested just returned 'Array' or am I missing something? Commented Oct 14, 2011 at 10:09

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.