【问题标题】:How to display custom html block in Drupal using theme?如何使用主题在 Drupal 中显示自定义 html 块?
【发布时间】:2012-08-20 09:35:46
【问题描述】:

有一些模块,在 hook_menu() 中定义了一些 url,需要在那里显示一些主题 (modules/mymodule/templates/mytheme.tpl.php)。 如何在需要的 url 上显示 mytheme.tpl.php 内容?

function mymodule_menu(){
    $item = array();

    $item['somemenu'] = array(
     'page callback' => 'somemenu_display',
  );

    return $item;
}

function somemenu_display(){
       return WHAT_IS_THIS_FUNCTION('modules/mymodule/templates/mytheme.tpl.php');
}

最好只显示这些内容,不带页眉/页脚。

【问题讨论】:

    标签: drupal themes hook-menu


    【解决方案1】:

    函数是 Theme()

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

    然后你需要像这样使用主题钩子:

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

    它现在在你的模块根目录中搜索 mytheme.tpl.php。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多