Drupal 7: how to get the body of a node

If in Drupal 7 we have to use the content of the body of a node as variable then we can get it through php, everything is really simple, we only have to give attention if the site uses only one language or if it is a multilanguage site.

If the site use only one language we can get the body of a node in this way:

$body = $node->body['und'][0]['value'];

If the site is a multilanguage site we can get the body of a node in this way:

$language = $node->language;
$body = check_markup($node->body[$language][0]['value'], $node->body[$language][0]['format'], $language);

Here a good explanation.

Tags: