node.tpl.php 中 <span class="submitted"><?php print
$submitted; ?></span>
sites/all/themes/mygarland/myminnelli/template.php 中
function
myminnelli_node_submitted($node) {
return t('Submitted by !username on @datetime',
array(
'!username' => theme('username', $node),
'@datetime' => format_date($node->created,'custom','Y-m-d H:i:s'),
));
}
见模块 node.module中注册了这个主题函数
function node_theme() {
return array(
'node' => array(
'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
'template' => 'node',
),
'node_list' => array(
'arguments' => array('items' => NULL, 'title' => NULL),
),
'node_search_admin' => array(
'arguments' => array('form' => NULL),
),
'node_filter_form' => array(
'arguments' => array('form' => NULL),
'file' => 'node.admin.inc',
),
'node_filters' => array(
'arguments' => array('form' => NULL),
'file' => 'node.admin.inc',
),
'node_admin_nodes' => array(
'arguments' => array('form' => NULL),
'file' => 'node.admin.inc',
),
'node_add_list' => array(
'arguments' => array('content' => NULL),
'file' => 'node.pages.inc',
),
'node_form' => array(
'arguments' => array('form' => NULL),
'file' => 'node.pages.inc',
),
'node_preview' => array(
'arguments' => array('node' => NULL),
'file' => 'node.pages.inc',
),
'node_log_message' => array(
'arguments' => array('log' => NULL),
),
'node_submitted' => array(
'arguments' => array('node' => NULL),
),
);
}
在 预处理函数中 function
template_preprocess_node(&$variables) {
$node = $variables['node'];
if (module_exists('taxonomy')) {
$variables['taxonomy'] = taxonomy_link('taxonomy terms', $node);
}
else {
$variables['taxonomy'] = array();
}
if ($variables['teaser'] && $node->teaser) {
$variables['content'] = $node->teaser;
}
elseif (isset($node->body)) {
$variables['content'] = $node->body;
}
else {
$variables['content'] = '';
}
$variables['date'] = format_date($node->created);
$variables['links'] = !empty($node->links) ? theme('links', $node->links, array('class' => 'links inline')) : '';
$variables['name'] = theme('username', $node);
$variables['node_url'] = url('node/'. $node->nid);
$variables['terms'] = theme('links', $variables['taxonomy'], array('class' => 'links inline'));
$variables['title'] = check_plain($node->title);
// Flatten the node object's member fields.
$variables = array_merge((array)$node, $variables);
// Display info only on certain node types.
if (theme_get_setting('toggle_node_info_'. $node->type)) {
$variables['submitted'] = theme('node_submitted', $node);
$variables['picture'] = theme_get_setting('toggle_node_user_picture') ? theme('user_picture', $node) : '';
}
else {
$variables['submitted'] = '';
$variables['picture'] = '';
}
// Clean up name so there are no underscores.
$variables['template_files'][] = 'node-'. $node->type;
}