template_preprocess_node
includes/theme.inc, строка 1908
- Версии
- 6
template_preprocess_node(&$variables)
Обрабатывает переменные для node.tpl.php
Большинство тем используют свою собственную копию node.tpl.php. Версия по умолчанию находится в 'modules/node/node.tpl.php'
.
Загляните туда, чтобы получить полный список переменных.
Массив $variables
содержит следующие аргументы:
$node
$teaser
$page
See also
node.tpl.php
Код
<?php
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;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии