How do I create a variable that my page.tpl.php file can access?
In Drupal theming, template preprocess functions are the functions that prepare the variables that can be used in a certain template. Template preprocess functions are executed one after another and they pass around an array with all variables. You can add your own in your theme's template.php, in the form of function THEMENAME_preprocess_TEMPLATENAME(&amp;$variables) { // Your code here. }.

If you're adding a value to a node object in a hook_node_load implementation, that probably looks something like this:

function mymodule_node_load($nodes, $types) {
  foreach ($nodes as $node) {
    $node-&gt;myvariable = 'somevalue';
  }
}


Now you want to access $node->myvariable in your page.tpl.php. For this, you don't even need to write a preprocess function, because Drupal already adds the current node object to the variables by default. (This happens in template_prepocess_page.) This means that you can simply add this to your page.tpl.php:

&lt;?php if ($node-&gt;myvariable): ?&gt;
  &lt;div class="myvariable"&gt;
    &lt;?php print $node-&gt;myvariable; ?&gt;
  &lt;/div&gt;
&lt;?php endif; ?&gt;