Passing Node Variables to Content and Blocks I'm really struggling with how to get variables created in page.tpl.php and node.tpl.php in rendered content and blocks. I hope I'm just missing something simple.

Basically, I'm trying to have a unique ID number passed around the site. To do that (as far as I know) I need to add it to all the links, IE /?a_uid=123456. 

I'm generating the random ID in success_preprocess_page (full code is below).

function success_preprocess_page(&amp;$variables, $hook) {
  //echo '&lt;pre&gt;'; print_r($variables); echo '&lt;/pre&gt;';\

        if (isset($_GET['utm_campaign']))   
            $adkey = $_GET['utm_campaign'];
        elseif (isset($_POST['utm_campaign']))  
            $adkey = $_POST['utm_campaign'];
        else
            $adkey = NULL;

        if (isset($_GET['a_uid']))  
            $a_uid = $_GET['a_uid'];
        elseif (isset($_POST['a_uid'])) 
            $a_uid = $_POST['a_uid'];
        else
            $a_uid = NULL;

    if ($adkey != NULL)
    {
        $a_uid = "123456";
    }
    $variables['adkey'] = $adkey;
    $variables['a_uid'] = $a_uid;

   if(isset($variables['a_uid'])){
    // add the flag to the node to say it's been set and there is only a single node to display
       if(isset($variables["page"]["content"]["system_main"]["nodes"]) &amp;&amp; count($variables["page"]["content"]["system_main"]["nodes"]) == 2){
            $keys = array_keys($variables["page"]["content"]["system_main"]["nodes"]);
           // Set a new variable called sidebar_first equal to true on the node.tpl level
           $variables["page"]["content"]["system_main"]["nodes"][$keys[0]]['#node']-&gt;a_uid = $a_uid;
      }
    }
}


Any links that are in page.tpl.php, ex:

&lt;a href="programs/?a_uid=&lt;?php echo $a_uid; ?&gt;"&gt;Programs&lt;/a&gt;


Display the correct $a_uid variable result of 123456.

And if I try to echo $a_uid in node.tpl.php, ex:

&lt;?php $a_uid = $node-&gt;a_uid; ?&gt;
&lt;?php //echo 'A_UID: '.$a_uid.'&lt;br&gt;&lt;br&gt;'; ?&gt;


Also displays 123456 fine.

But if I try anything like this in my content pages (even with them set as PHP Code Text Format, which correctly processes other PHP code), everything result is blank.

For instance, I currently have a content page that has this in it, trying to hit all the marks I can think of:

&lt;?php echo $a_uid; ?&gt;
&lt;?php print $a_uid; ?&gt;
&lt;?php echo $node-&gt;a_uid; ?&gt;
&lt;?php echo $content-&gt;a_uid; ?&gt;
&lt;?php print $node-&gt;a_uid; ?&gt;
&lt;?php print $content-&gt;a_uid; ?&gt;
&lt;?php print ($page['a_uid']); ?&gt;
&lt;?php print ($node['a_uid']); ?&gt;


Not a single one of those displays anything.

As far as I can tell it seems like the variable is just not getting passed to the content? I just don't understand why, or how to fix it. 

I assume this is standard, but this is how my content is being called in node.tpl.php:

print render($content);


I am also having the same problems in my header and footer blocks. Those are being called from page.tpl.php as:

&lt;?php print render($page['footer']); ?&gt;
&lt;?php print render($page['header_button']); ?&gt;


Any help with this would be greatly appreciated. Thanks! Oh and 123456 is just a placeholder in here for my random unique ID generator code :)
Apparently I was just looking at my process wrong this morning. I went back to it after reading what you wrote and realized I could just use  in my html.tpl file and it would handle everything I need it to do. 

But thank you for answering! I'm not sure how but what you posted led me in the right direction after I was reading your links :)