How to Create a single page within a module and set page variables? I create a page within my custom module with the following code:

function mymodule_menu(){
    $items['product-detail'] = array(
        'title' =&gt; t('Product detail'),
        'page callback' =&gt; '_mymodule_product_detail',
        'variables' =&gt; array('var1' =&gt; "Hello World Attempt #1"),
        'type' =&gt; MENU_CALLBACK,
        'access callback' =&gt; TRUE,
     );

 function _mymodule_product_detail(){
      // global $var1 = "Hello Workd Attempt #3";

     return array('variables' =&gt; array("var1" =&gt; "Hello World Attempt #2") , '#markup' =&gt; '&lt;p&gt;This is some markup content displayed correctly in the page&lt;/p&gt;');
 } // function


It renders the template, sets the title and display the markup (content of the page). However, I would like to fill some variables defined in the page.tpl.php and I don't know how to send these parameters, I tried with the variables key in the code but nothing is written. I want to display the message "Hello World Attempt #?" in the place in page.tpl.php where I have the code &lt;?php if(isset($var1)) print $var1; ?&gt;

I have been able to reach my goal with the following code, but using GLOBAL, which is not adequate:

function mymodule_preprocess_page(&amp;$variables) {
   global $var1;
if(isset($var1) &amp;&amp; $var1 != "") $variables["var1"] = $var1;

}


The global $var1 is set to $var1 = "HELLO WORLD Attempt #3" in the _mymodule_product_detail() function above (lines commented).
The link in my comment may not get you all the way there so I am adding a working example. Assuming everything else in your code is working changing this line

 return array('variables' =&gt; array("var1" =&gt; "Hello World Attempt #2") , '#markup' =&gt; '&lt;p&gt;This is some markup content displayed correctly in the page&lt;/p&gt;');


to

$output = array("var1" =&gt; "Hello World Attempt #2" , '#markup' =&gt; '&lt;p&gt;This is some markup content displayed correctly in the page&lt;/p&gt;');
return theme('page', $output);


Added the entire $output array to the hook_preprocess_page`.

NOTE: You may have to add a theme callback to your menu item. Example here.