In a module I am developing, I am using the following code.
function mymodule_page_alter(&$page) {
global $user;
$page['sidebar_first'] = array(
'#markup' => 'text for first sidebar'
);
}
How can I load the HTML template file to the first side bar, and pass few variables to this?
Maybe this will be something like the following code.
$page['sidebar_first'] = array(
'#template' => path,
'#variables' => array(),
);
You need to use the “#theme” attribute, such as in the following code.
#themetells to Drupal which theme function needs to be called; the other properties, if they are already used for a different purpose, are used as variable names to pass to the theme function, or the template file, if one is used.In the example, theme_table() will receive the following array.
This can be done even with those theme functions that really use a template file.
You define a theme function in your hook_theme(), using the necessary keys used for a theme function that uses a template file, such as in the following code.
The theme function would be then used with something similar to the following code.
The variables that don’t get an explicit value will get the default one reported in
hook_theme(); in this case, the default value for the used variables isNULL.