Народ, сможет кто подсказать?
Есть кусок кода в template.php
function phptemplate_preprocess_page(&$variables) {
if ($node = menu_get_object()) {
$variables['node'] = $node;
$suggestions = array();
$template_filename = 'page';
$template_filename = $template_filename . '-' . $variables['node']->type;
$suggestions = $variables['template_files'];
$suggestions[] = $template_filename;
$variables['template_files'] = $suggestions;
}
}
if ($node = menu_get_object()) {
$variables['node'] = $node;
$suggestions = array();
$template_filename = 'page';
$template_filename = $template_filename . '-' . $variables['node']->type;
$suggestions = $variables['template_files'];
$suggestions[] = $template_filename;
$variables['template_files'] = $suggestions;
}
}
он дает возможность создавать файлы page- тип материала .tpl.php
Причем вот эта строка
$suggestions = $variables['template_files'];
как было обещано призвана учитывать предыдущие кандидаты в шаблоны (page-front.tpl.php)
Но теперь с этим кодом у меня не работает ни page-node-edit.tpl.php ни page- тип материала -edit.tpl.php
Как заставить их работать?
Комментарии
<?php
function phptemplate_preprocess_page(&$vars) {
if (arg(0) == 'node' && is_numeric(arg(1)) && !arg(2)) {
$vars['template_files'][] = 'page-' . $vars['node']->type;
}
}
?>
xxandeadxx, спасибо, более красиво и эффективно.
А гловное что и page-node-edit.tpl.php тоже работает.
з.ы.
жаль только что page- тип материала -edit.tpl.php не катит, а то коду цены бы небыло. (но мне и этого хватает пока)
+
Я использую такой код(грязный хак:)), он работает с page-тип материала.tpl.php и page-тип материала-edit.tpl.php
<?php
function phptemplate_preprocess_page(&$vars) {
//page.tpl.php for node type
if ($vars['node']->type != "")
{
$vars['template_files'][] = "page-node-".$vars['node']->type;
if(arg(2)==='edit') $vars['template_files'][] = "page-node-{$vars['node']->type}-edit";
}
}
?>