Return NID for a Content Type

This little diddy evaluates a content type and, if it checks out, returns the NID for the specific node / page!

Drupal 5 Solution

You can add this theme function to your template.php and call it anywhere you need to know the NID in a php text-field

<?php
function theme_name_return_nid($what_content_type){
      // this returns an array!
     if(arg(0) == 'node' && is_numeric(arg(1))){
         // now we can load the node
         $node = node_load(array('nid' => arg(1)));
         if($node->type == $what_content_type) {
           // set current node ID as argument
           $args[0] = arg(1);
           return $args;
        }
    }
}
?>

Drupal 6 Solution

<?php
function theme_name_return_nid($what_content_type){
     // using Drupal 6 menu_get_object()
      if (($node = menu_get_object()) && $node->type == $what_content_type) {
          return $node->nid;
       }
}
?>