0

作成しているモジュールがあり、その目的は、特定のタイプのデータをインポートし、そのデータに応じてノードに追加することです。

これを行うには、システムがインポートするためにデータが保存されている場所をユーザーが入力できるページを作成する必要があります。

これを行うには、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のような自分のページを作成するにはどうすればよいですか?

4

1 に答える 1

6

2つのこと。まず、パスはアイテムの配列キーに含まれている必要があります。次に、アクセス引数またはアクセスコールバックがないと、常にアクセスが拒否されます。ドキュメントを読み、例に従うと、ここで役立つ場合があります。

function lbar_image_importer_menu(){
    $items = array();
    $items['admin/content/lbar_image_importer'] = array(
        'title' => "Import LBar Images",
        'description' => "Innitiate an importation of LBar images from a ZIP file.",
        'page callback' => 'drupal_get_form',
        'access callback' => true,
    );
    return $items;
}

drupal_get_form値がなければ何もしませんpage arguments

于 2011-01-04T20:59:10.877 に答える