0

Drupal 7 のモジュールに取り組んでいます。コンテンツ タイプのテンプレートを node--[content type].tpl.php として定義し、「themes/[selected theme]/template」ディレクトリに配置しました。代わりに、このテンプレートを「モジュール」ディレクトリに保持したいと思います。そのため、モジュールをインストールするときに、選択したテーマ フォルダーに毎回ファイルを配置する必要はありません。これを行う方法はありますか?

よろしくお願いします。

担当者が 10 人未満なので、自分の質問に答えることができないので、質問を変更します

以下は私のために何らかの方法で働いています。ケースノード編集フォームビューとノードビューの両方

function [content type]_theme() {
   return array(
    '[content type]_node_form' => array(
          'arguments' => array(
              'form' => NULL,
            ),
        'template' => 'node--[content type]--edit',
        'render element' => 'form',
        ),
    'node__[content type]' => array (
          'variables' => array(),
          'template' => 'node--[content type]' ,
          'base hook' => 'node',
          'path' => "sites/all/modules/[content type]_update/[content type]_update/[content type]/",
        ),
    );
}

これは完全には理解できませんが、機能しています。

4

2 に答える 2

0

以下の形式を使用して、テンプレート パスを指定できます。その後、tpl ファイルをモジュール フォルダーに配置できます。

function MODULENAME_theme() {
    return array(
        'yourcustom_theme' => array(
            'template' => 'mypage', // template file called mypage.tpl.php
            'path' => drupal_get_path('module', 'MODULENAME'),
        )          
    );
}
于 2014-06-27T06:09:57.040 に答える