Drupal contact form use tpl.php 將聯絡表單的內容移到 tpl.php

其實我做的是一個contact module 的擴充, cck 的 email field
它可以建立一個送到特定 email 欄的聯絡表單, 是建基於內建的聯絡表單的擴展
而我需要將它的 html 完全改變, contact form 的修改應該很類似

步驟:
先在theme 注冊一個使用的 theme hook:

<?php
//template.php
mytheme_theme() {
 
$hooks['email_mail_page_form'] = array(
   
'template' => 'email-mail-page-form',
   
'arguments' => array('form' => NULL),
   
// other theme registration code...
 
);
  return
$hooks;
}
?>

然後在 theme 內新建一個 email-mail-page-form.tpl.php:

//email-mail-page-form.tpl.php
<?php
kprint_r
($form);
?>

但和前文所記, 如果需要使用 hook_form_alter() 的話
便需要自建一個 module, 而不可以好像上例般直接在 theme 內修改

Google