6
複数のテンプレートページに再利用して変数を渡すことができるhtmlスニペットを作成するにはどうすればよいですか?このようないくつかの(しかし、明らかに少し複雑):カスタムモジュールでDrupal - テンプレート内でサブビューをレンダリングする/部分的に
複数のテンプレートページに再利用して変数を渡すことができるhtmlスニペットを作成するにはどうすればよいですか?このようないくつかの(しかし、明らかに少し複雑):カスタムモジュールでDrupal - テンプレート内でサブビューをレンダリングする/部分的に
<ul>
<? foreach ($items as $item): ?>
<li><?=$item?></li>
<? endfor; ?>
</ul>
おかげで、その後、テンプレート内からtheme()
メソッドを呼び出します。テンプレートで
mymodule_theme($existing, $type, $theme, $path) {
return array(
'my_theme_name' => array(
'template' => 'my_template_file_name', // without the .tpl.php extension
'variables' => array(), // to define default values for passed variables
)
);
}
:
theme('my_theme_name', array('arg1' => 'val1', 'arg2' => 'val2'));
あなたのモジュールで