Drupal 7 で。
テンプレートファイルで /node/add/content-type を page--node--add--content-type.tpl.php としてテーマにしたいと思います。
私を助けてください。
使用する必要があります
page--node--add-- content_type .tpl.php
それ以外の
page--node--add-- content-type .tpl.php
ダッシュ (-) の代わりにアンダースコア (_)
前処理関数の提案としてテンプレートを追加する必要があります。または、目的のテンプレートを使用するフォームのカスタム テーマ関数を作成することもできます。これは Drupal 6 で行われた方法と非常に似ていますが、テーマで form_alters を実行できるのは今だけです。
ノードフォームの tpl ファイルを追加しています。このためには、テーマの下の template.php で tpl ファイル名を定義する必要があります。
例: 以下の例では、 contact_site_formはコンテンツ タイプのフォーム ID です。
your_theme_name_theme() {
$items['contact_site_form'] = array(
'render element' => 'form',
'path' => drupal_get_path('theme', 'your_theme_name') . '/templates',
'template' => 'contact-site-form',
);
}
上記で指定したパスの場所にファイル contact-site-form.tpl.php を作成します。
<?php echo render($form['name']); ?>
<?php echo render($form['mail']); ?>
.
.
.
<?php print drupal_render_children($form); ?>
特定のメソッドで各要素を個別にレンダリングできます。
この関数を template.php に追加できます。フォームを print_r() して、フィールドが何であるかを確認できます。
function yourThemeName_form_yourFormID_alter(&$form, &$form_state, $form_id) {
// Modification for the form with the given form ID goes here. For example, if
// FORM_ID is "user_register_form" this code would run only on the user
// registration form.
print_r($form);
}