Templates 如何覆盖特定内容类型的node.tpl.php并在单个页面中显示所有内容?
我是drupal的新手。我正在创建一个内容类型“新闻”。每次我创建一个新闻类型的内容时,它都会显示在页面中,比如…/drupal/?q=node/6、/drupal/?q=node/7等等 我真正需要的是在一个页面中列出所有这些内容,并在一个模板文件中编辑它们。在这里我得到的问题是什么样的模板文件名 尝试: 我尝试过使用以下名称,并且在mytheme/template目录中有“mytheme\u preprocess\u page()”Templates 如何覆盖特定内容类型的node.tpl.php并在单个页面中显示所有内容?,templates,drupal-7,preprocessor,drupal-theming,Templates,Drupal 7,Preprocessor,Drupal Theming,我是drupal的新手。我正在创建一个内容类型“新闻”。每次我创建一个新闻类型的内容时,它都会显示在页面中,比如…/drupal/?q=node/6、/drupal/?q=node/7等等 我真正需要的是在一个页面中列出所有这些内容,并在一个模板文件中编辑它们。在这里我得到的问题是什么样的模板文件名 尝试: 我尝试过使用以下名称,并且在mytheme/template目录中有“mytheme\u preprocess\u page()” 1.node--news.tpl.php 2.no
1.node--news.tpl.php
2.node--type--news.tpl.php
3.node-type-news.tpl.php
This is my
function ppi_preprocess_page(&$variables) {
if (isset($variables['node']) && isset($variables['node']->custom_template['und'][0]['value'])) {
$custom_template_value = $variables['node']->custom_template['und'][0]['value'];
$templates_directory = dirname(__FILE__)."/templates";
$template_file_path = "$templates_directory/{$variables['node']->type}--{$custom_template_value}.tpl.php";
$template_name = "{$variables['node']->type}__{$custom_template_value}";
if(file_exists($template_file_path)) {
$variables['theme_hook_suggestions'][] = $template_name;
}
if ((arg(0) == 'node') || (arg(1) == 'edit' || arg(2) == 'news')) {
$vars['template_files'][] = 'page-node-edit-news';
}
}
}
我还更改了$vars['template\u files'][]='page node edit news'哪里出了问题?使用以下步骤:
除了视图和自定义模块之外,是否还有其他选项可以这样做,就像我们在头版或特定块中设置主题一样?
This can be possible through the name like page--node--{custom_content_type}.tpl.php
In this case it shuld be **page--node--news.tpl.php**