作成しているモジュールがあり、その目的は、特定のタイプのデータをインポートし、そのデータに応じてノードに追加することです。
これを行うには、システムがインポートするためにデータが保存されている場所をユーザーが入力できるページを作成する必要があります。
これを行うには、hook_menuにフックして、次のようなページを作成します。
function lbar_image_importer_menu(){
$items = array();
$items[] = array(
'path' => "admin/content/lbar_image_importer",
'title' => "Import LBar Images",
'description' => "Innitiate an importation of LBar images from a ZIP file.",
'page callback' => 'drupal_get_form',
);
return $items;
}
次のようにhook_form_alter関数にフックして、使用するフォームにデータを入力します。
function lbar_image_importer_form_alter(&$form, &$form_state, $form_id) {
$form['admin']['lbar_zip_loc'] = array(
'#type' => 'textfield',
'#title' => 'Location of LBar Zip file: ',
'#description' => 'This is where one or many of the lbar zip files are located. If this is a file, it will access only that zip file. If it is a directory it will open all zip files in that directory.',
);
$form['admin']['submit'] = array(
"#type" => "submit",
"#value" => "Import",
'#submit' => array('lbar_image_importer_submit'),
);
return $form;
}
しかし、私は運がありません。フォーム要素を検索フォームに追加し、管理者/コンテンツページを再表示します。admin / content / nodeのような自分のページを作成するにはどうすればよいですか?