Passing variables from modulefunction to theme I have a custom theme and a custom module. The module shows users. Every user has its specific image (that can be uploaded, changed). The location/name of this file is in the database.

I have an template with specific layout for that page: page--uspage.tpl.php
In this page, I need the location from the database when I access uspage.

$items['uspages'] = array(
    'title' =&gt; 'User pages', //page title
    'description' =&gt; 'User pages',
    'page callback' =&gt; 'show_uspages'
);

$items['uspage/%'] = array(
    'title' =&gt; 'User page',
    'description' =&gt; 'User page detail',
    'page callback' =&gt; 'show_uspage',
    'page arguments' =&gt; array(1),
    'access callback' =&gt; TRUE,
     'type' =&gt; MENU_CALLBACK,
);


I have a lot of other pages that doesn't need that. So I can't use preprocess_page.

What's the easiest and best way to pass an array with the backgroundinformation from the function show_uspage to page--uspage.tpl.php ?
Short but painfully: there is no way to achieve that. The page.tpl expects that your part of the code is a renderable array or HTML output fully generated in your page callback show_uspage(). Your part of the code is injected into the $variables of hook_preprocess_page() where ever the content block is placed in region settings for your theme. Your page callbacks really just handles the part of the output where the content block is placed. You can not store any data from your page callback for later use in theme layer or send the data by any mean to the page preprocess function or any other theming function for the page.tpl.

The only way would be to use hook_preprocess_page() and to add any data here again. You must use this hook even when you add data just for a specific page - you just need to assure to do that in this case and not on every page. Maybe by checking on which path the user is (like if(current_path == 'uspages')). 

Another way would be to store the data in session in re-use it in hook_preprocess_page.