2

我是 drupal 的新手。我正在创建一个内容类型 "news" 。每次我创建新闻类型的内容时,它都会显示在页面中,例如 .../drupal/?q=node/6, .../drupal/?q=node/7 等等。

我到底需要什么我想在一个页面中列出所有这些内容并在一个模板文件中编辑它们。在这里我遇到问题,模板文件名是什么?

尝试:我尝试使用以下名称,并且在 mytheme/template 目录中有“mytheme_preprocess_page()” 。

  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_files'][] = 'page-node-edit-news'我哪里出错了?

4

2 回答 2

1
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**
于 2013-06-17T11:33:11.303 回答
0

使用此步骤:

  1. 安装视图模块
  2. 运行视图和视图 ui
  3. 使用链接结构/视图
  4. 重新审视您的内容类型
  5. 询问您需要的字段,然后根据需要构建您的页面
  6. 如果需要,您可以为视图设置主题
于 2013-04-12T13:42:17.333 回答