在模块中覆盖node.tpl.php
我创建了一个模块,该模块应该能够显示某种内容类型的内容。该显示有点复杂,为了能够将其关闭并将所有内容分组在一起,我为此创建了一个模块。 但是最后,它应该只是使用自定义的.tpl.php文件覆盖普通的node.tpl.php。当我将文件放在模板文件夹中时,它会被拾取,页面按预期显示,但是当文件在模块文件夹中时,我无法使它工作。 我阅读了很多有关regsiter .tpl文件和预处理的内容,但没有任何内容可以组合我所需的内容。 这就是我到目前为止 function apps_theme($existing, $type, $theme, $path) { $items = array( 'node--app' => array( 'template' => drupal_get_path('module', 'app') . '/node--app', 'variables' => array('node' => (object)array()) ) ); return $items; } function apps_preprocess_node(&$vars) { $variables['theme_hook_suggestions'][] = 'node__app'; }