How to get body field within THEME_page_alter Possible Duplicate:
  How do I access node body from template.php?  




I've actually asked this previously, but I received an unsatisfactory answer, and thus my question was forgotten, as it was marked 'answered'.

My aim is to have a meta description on my front page, and a meta description for each of my blog entries, I'm using THEME_page_alter to achieve this. Both the metatag and metatags_quick modules don't seem to work properly despite several hours of changing settings.

Here is the code located in my template.php:

function vertaxe_page_alter($page) {
    $description = 'My default desc';
    if (!empty($page['content']['system_main']['nodes']) &amp;&amp; is_array($page['content']['system_main']['nodes'])) {
        foreach ($page['content']['system_main']['nodes'] as $nid =&gt; &amp;$content) {
            if ($content['#node']-&gt;type == 'blog') {
                $description = '';
            }

        }
    }

    $meta_description = array(
        '#type' =&gt; 'html_tag',
        '#tag' =&gt; 'meta',
        '#attributes' =&gt; array(
            'name' =&gt; 'description',
            'content' =&gt;  $description
        )
    );

    drupal_add_html_head( $meta_description, 'meta_description' );

}


How do I get the node's body field for use in my description?
According the hook_page_alter() documentation you should be able find the body like that.

$description = $page['content']['system_main']['nodes'][$nid]['body'];


But if you still have the problem you can display all data from your page with the help of Devel module or simply with a print_r($page); and look where is the content that you're looking for.