Preprocess function for node.tpl.php file
To create a variable for any type of node you should use yourtheme_preprocess_node() function, and in this fuction you should specify a type of node.

Example:



/**
 * Override or insert variables into the node templates.
 *
 * @param $variables
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("node" in this case.)
 */

function YOURTHEME_preprocess_node(&amp;$variables, $hook) {

  //$variables['sample_variable'] = t('Lorem ipsum.');
  // Optionally, run node-type-specific preprocess functions, like
  // YOURTHEME_preprocess_node_page() or YOURTHEME_preprocess_node_story().
  //$function = __FUNCTION__ . '_' . $variables['node']-&gt;type;
  //if (function_exists($function)) {
  //  $function($variables, $hook);
  //}

  // define $node object, so it's be easier to use it
  $node = $variables['node'];

  // add variables to node--nameofnodetype.tpl.php file
  if ($node-&gt;type == 'nameofnodetype'){

      // $variables: an array with variables
      // you need to add one, so just define it
      $variables['my_variable'] = 'whatever';

      // also you can rewrite those variables which already exists
      // for example variable: $title
      $variables['title'] = t('The new title');
  }
}


In your node--nameofnodetype.tpl.php file:

// check if your new variable exist
print $my_variable;


 * Don't forget replace 'YOURTHEME' to your theme name