[Drupal] Simple steps of building a module theme

1. Scene of building a theme.

代码
/**
* Implementation of hook_block().
*/
function mymodule_block($op = 'list',$delta = 0, $edit = array()) {
switch ($op) {
case 'list':
$blocks[0]['info'] = t('my testmodule');
return $blocks;
case 'view':
$content = theme('mymodule_get_sth','David Lee', 'David Lee 2.0');
$blocks['subject'] = t('Just atest');
$blocks['content'] = $content;
return $blocks;
}
}

 

 

2. Build a function: hook_theme()

function mymodule_theme() {
return array(
'mymodule_get_sth' => array(
'arguments' => array('arg_1' =>NULL, 'arg_2' => NULL),
)
,
);
}

 

3. Build a function: theme_hook()

function theme_mymodule_get_sth($arg_1,$arg_2) {
return '<divclass=”mymodule_theme”>'.$arg_1.' and '.$arg_2.'</div>';
}

原文地址:https://www.cnblogs.com/davidhhuan/p/1846031.html