1

URL_home()によって呼び出されるという名前の Drupal 7 関数があります。home

この関数では、HTML 出力を生成して返したいと考えています。結果の HTML をユーザーに表示する必要があります。実際には、関数内に HTML タグ (div、tables、b...) を埋め込み、ユーザーに返します。実行されますが、おそらくテンプレートやテーマを使用して、より良い方法が必要だと思います。_homeノード/別の Drupal オブジェクトでなくても、関数にテンプレートを適用する方法はありますか?

4

1 に答える 1

2
if the "home" url is being created using modules then the following might be useful for you.

In your module file create
function modulename_theme($existing, $type, $theme, $path)
   {
   $theme_hooks = array(
    'home' => array(
      'template' => 'home',//name of template file will be home.tpl.php
      'path' => $path . '/templates',
      'variables' => array(
      ),
    ));
     return $theme_hooks;
    }
    //As _home is the callback function for "home" url
    function _home($node)
    {
    return theme('home', array('node' => $node));
    }



Now under your module create a templates folder & in that create home.tpl.php & place your html in that file..
于 2012-06-11T07:29:14.207 に答える