2013-04-12 19 views
2

我是drupal的新手。我正在創建一個內容類型「新聞」。每次我創建了類型新聞的內容時,它都會顯示在頁面中,如.../drupal /?q = node/6,.../drupal /?q = node/7等等。如何覆蓋特定內容類型的node.tpl.php並在單個頁面中顯示所有內容?

我到底需要什麼,我想列出所有這些內容在一個單一的頁面,並編輯它們在一個單一的模板文件。在這裏我得到的問題是,模板文件名是什麼?

嘗試: 我試圖用下面的名字和我也有「mytheme_preprocess_page()」在mytheme的/模板目錄。

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'; 
    } 
    } 
} 

我也改變了$瓦爾[「template_files」] [] =「頁面節點編輯新聞」我要去的地方錯了嗎?

回答

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** 
0

使用此步驟:

  1. 安裝看法模塊
  2. 運行的觀點和看法UI
  3. 使用鏈接結構/ viwes
  4. 使您的內容類型的新觀點
  5. 問您需要的字段然後根據您的意願建立您的頁面
  6. 如果您想
+0

是否有任何其他選項,除了視圖和自定義模塊,以做到這一點像我們的主題化的頭版或特定塊? – Drupalie