How do I test for node type to print a variable from template.php? In Drupal 7, you can use the following in template.php to test for the presence of a node type:

function MYTHEME_preprocess_node(&amp;$variables) {
if ($variables['type'] == 'NODETYPE') { 
***CUSTOM CODE****
}


In Drupal 7, you can use the following in template to create a variable which can be printed out in your page.tpl.php file:

function MYTHEME_preprocess_page(&amp;$variables) {
      $variables['greeting'] = 'Custom Greeting';   
} 


But how do you combine the two, to create a variable inside of template.php (that can be printed in page.tpl.php) which changes according to the node type?

I would have thought the following would work:

    function MYTHEME_preprocess_page(&amp;$variables) {
              if ($variables['type'] == 'NODETYPE') { 
  $variables['greeting'] = 'Custom Greeting';
    }
    } 


But it doesn't work. Why is this? (Using the same code on MYTHEME_preprocess_node also does not work).

Thanks for any help!
Each template has a different set of variables available. The variables available in a given theme is generally documented in the comment section at the top of the file. You can consult this documentation on http://api.drupal.org.

The node type is not directly available as a variable in the page.tpl.php. However, you have the $node object which has a type property:

function MYTHEME_preprocess_page(&amp;$variables) {
  if (!empty($variables['node']) &amp;&amp; $variables['node']-&gt;type == 'NODETYPE') {
    $variables['greeting'] = 'Custom Greeting';
  }
}