Skip to content

Instantly share code, notes, and snippets.

@v1talii-dev
Last active August 29, 2016 13:31
Show Gist options
  • Save v1talii-dev/5bf05148110a0ff923c44a49813ae500 to your computer and use it in GitHub Desktop.
Save v1talii-dev/5bf05148110a0ff923c44a49813ae500 to your computer and use it in GitHub Desktop.
D7: theme template in module
<?php
# ------------------------------------------------------------------------------
# test.module
# ------------------------------------------------------------------------------
/**
* Implements hook_theme().
*/
function test_theme() {
return array(
'test_panel' => array(
'variables' => array(),
'template' => 'test-panel',
'path' => drupal_get_path('module', 'test') . '/templates'
),
);
}
// Some callback function..
function test_page() {
$template = theme('test_panel', array(
'data' => array(
'test' => 'data'
)
);
return $template;
}
# ------------------------------------------------------------------------------
# templates/test-panel.tpl.php
# ------------------------------------------------------------------------------
<code><?php print_r($data); ?></code>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment