Correct way of passing variables between hook and tpl.php I asked a similar question a few months ago, but the truth is that there is very little information about the correct way of doing this.

The simplest way is to use the arg() function, but as the docs clearly state, that is the wrong way of doing it. While trying to follow the correct steps, this is what I have so far:

A menu with the necessary paths:

$items['products/search/%/%'] = array(
        'title'             =&gt; 'Products search filtering',
        'description'       =&gt; 'Show review categories.',
        'page callback'     =&gt; 'ThemeSearchProducts',
        'page arguments'    =&gt; array(2,3),
        'access callback'   =&gt; 'user_access',
        'access arguments'  =&gt; array('access content'),
        'type'              =&gt; MENU_NORMAL_ITEM,
        'file'              =&gt; 'includes/mymodule_reviews.inc',
);


These arguments are sent via ... arguments (sorry for the joke). to the themesearchproducts function

/**
 * THEME List of reviewable products
 *
 */
function ThemeSearchProducts($arg1, $arg2){

//  $output = theme('search_products', $arg1);
  $output = theme('search_products', 'test');

  echo 'args in theme: ' . $arg1 . $arg2 . ' || ';


  return $output . theme('pager', 10);
}


The echo works fine, but now the question becomes how do I send this variable to the hook_theme of the module, and from there to the tpl.php? I have something like the following:

function MYMODULE_theme ($existing, $type, $theme, $path) {
    $path = drupal_get_path('module', 'MYMODULE'); // . '/templates';
    // ADD THE templates DIRECTORY
    $path = $path . '/templates'; 


    return array(
            // as in 'theme('verbose_method',...)
            'main_reviews' =&gt; array(
            'template' =&gt; 'MYMODULE-main_page_reviews',
            'path' =&gt; $path,
            'variables' =&gt; array('forums' =&gt; NULL, 'topics' =&gt; NULL),
            ),


as you can see, the module now calls the tpl in templates/MYMODULE-main_page_reviews.tpl.php, but I cannot find the correct way to send a variable from  the previous callback to the hook_theme. Adding a new argument to the MYMODULE_theme throws an error, and I cannot get rid of it, not even by adding (for example) this new argument in ThemeSearchProducts, like this:

 $output = theme('search_products', 'test');


Is using variable_set also incorrect? I'm trying to follow the "Drupal Standard Practices" as much as possible, but this last step is eluding me.
The arguments you pass to theme() when you invoke a theme function are not passed to hook_theme(), and from there to the template file. They are passed directly to the theme function, or the template file, in the case the theme function is using it.

hook_theme() defines the arguments used from the theme function. How those arguments are then passed to theme(), and to the theme functions, depends from the Drupal version:


With Drupal 7, they are all passed in an array, which in your case is similar to the following one:

array('forums' =&gt; $forum, 'topics' =&gt; $topic);


hook_theme() defines the default arguments used for the variables when no value is given. In your case, you could use array('forums' =&gt; $forum); and NULL will be used for 'topics'. (Replace $forum with the value you need to use.)
With Drupal 6, you pass the variable as single arguments to theme(), for example as in theme('search_products', $forum, $topic). As with Drupal 7, the default value is used when you don't pass that argument.


In both the cases, the variable declared for the theme function in hook_theme() is the name of the variable passed to the template file. In your case, $topics, and $forums are two variables accessible from the template file.

As side note, the template file you declare in hook_theme() with "template" for your theme_search_products() needs to be search-products, or search_products; Drupal will add the extension .tpl.php to the name, when looking for the template file. You cannot have a theme function that is declared as example_one, and the template file that declared to be example_two.
Also, you are trying to use theme_search_products(), but your hook_theme() implementation doesn't define that theme function. The code you are showing contains the definition for theme_main_reviews(). If the theme function you are calling is not defined from another module, that code will not work.