2012-03-21 5 views
6

어떻게 여러 템플릿 페이지에서 재사용 할 수 있고 변수를 전달할 수있는 html 코드를 만들 수 있습니까? 이 같은 일부 (하지만 분명 조금 더 복잡) :Drupal - 템플릿 내 하위 뷰 렌더링/부분

<ul> 
    <? foreach ($items as $item): ?> 
    <li><?=$item?></li> 
    <? endfor; ?> 
</ul> 

감사

답변

8

사용자 정의 모듈을 사용 hook_theme() 후 템플릿 내에서 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')); 
모듈에서