doumi1912 2012-08-20 00:42
浏览 43
已采纳

如何覆盖位于模块文件夹中的备用模板(.tpl.php)文件的路径?

I want to create a custom theme for a specific page. (e.g. www.domain.com/roster/%/home) For this purpose I've created the following file and placed it within the templates folder of my current theme (bartik): page--roster--home.tpl.php.

It overrides the default theme as desired, but I want to keep all files related to my module within its folder.

My question is, how can I place the file within my module's folder and still have Drupal 7 pick it up?

  • 写回答

1条回答 默认 最新

  • douao1926 2012-08-20 09:51
    关注

    use Theme()

    return theme('some_theme_function_template', array('aValues' => $someArray));
    

    Then you need to use the theme hook like this:

    function my_module_name_theme() {
        return array(
            'some_theme_function_template' => array(
                'template' => 'mytheme',
            ),
        );
    }
    

    It now searches for mytheme.tpl.php in the root of you're module.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?