Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drupal テーマ開発入門講座 第7回 テーマ設定のカスタマイズ

Sponsored · Ship Features Fearlessly Turn features on and off without deploys. Used by thousands of Ruby developers.

Drupal テーマ開発入門講座 第7回 テーマ設定のカスタマイズ

More Decks by アクイアジャパン Acquia Japan

Other Decks in Programming

Transcript

  1. – ςʔϚͷΠϯετʔϧ – ςʔϚͷΞϯΠϯετʔϧ – σϑΥϧτςʔϚͷ੾Γସ͑ – ৽͍͠ςʔϚͷ௥Ճ 
 ʢUpdate

    ManagerϞδϡʔϧͰఏڙʣ 
 ※ςʔϚͷ௥Ճ͸Ϟδϡʔϧಉ༷ɺcomposerͰߦ͏ํ๏͕ਪ ঑͞Ε͍ͯ·͢ɻ – ݸʑͷςʔϚݻ༗ͷઃఆ ؅ཧϝχϡʔʮςʔϚʯͰͰ͖Δ͜ͱ
  2. <?php use Drupal\Core\Form\FormStateInterface; function marucha_form_system_theme_settings_alter(&$form, FormStateInterface $form_state) { $form['twitter_url'] =

    array( '#type' => 'textfield', '#title' => t('Twitter URL'), '#description' => t(“TwitterΞΧ΢ϯτͷURLΛೖྗ͠·͢ɻ"), '#default_value' => theme_get_setting('twitter_url'), ); } γϯϓϧͳΧελϚΠζ theme-settings.php ઃఆϖʔδʹςΩετ ϑΟʔϧυ͕௥Ճ͞Ε· ͢ɻ
  3. hook_form_system_theme_settings_alter() ͷ࢓༷ – ςʔϚ͕ςʔϚݻ༗ͷઃఆϑΥʔϜΛมߋͰ͖ΔΑ͏ʹ͢ΔϑοΫؔ਺Ͱ͢ɻ – ͜ͷϑοΫΛ࢖༻͢ΔͱɺϑΥʔϜཁૉͷ௥ՃɺσϑΥϧτ஋ͷมߋɺϑΥʔ Ϝཁૉͷ࡟আͳͲɺDrupalͷForm APIͰڐՄ͞Ε͍ͯΔํ๏ͰςʔϚݻ༗ͷઃ ఆϑΥʔϜΛมߋͰ͖·͢ɻ 


    – ؔ࿈υΩϡϝϯτ – function hook_form_system_theme_settings_alter (Drupal API) – function hook_form_FORM_ID_alter (Drupal API) – Introduction to Form API (Drupal Wiki) – Form and render elements (Drupal API)