Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Drupal テーマ開発入門講座 第7回 テーマ設定のカスタマイズ
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
アクイアジャパン Acquia Japan
June 29, 2022
Programming
190
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Drupal テーマ開発入門講座 第7回 テーマ設定のカスタマイズ
https://www.acquia.com/jp/events/webinars/drupal-theming-development-vol7
アクイアジャパン Acquia Japan
June 29, 2022
More Decks by アクイアジャパン Acquia Japan
See All by アクイアジャパン Acquia Japan
Auth0 by OktaとDrupalで実践!認証付きアプリケーションの新しいアプローチ
acquiajp
0
240
Drupal 10.3の新機能紹介ウェビナー
acquiajp
0
290
DrupalCon Portland 2024 総まとめウェビナー
acquiajp
0
140
開発者必見!Acquia Cloud IDEで最高のDrupal開発を始めよう
acquiajp
0
250
触って学ぶ!デジタルアセット管理 Acquia DAM ハンズオンウェビナー
acquiajp
0
61
DrupalCon Lille 2023 総まとめウェビナー
acquiajp
0
120
コンテンツ設計手法で変更に強いアプリケーションを実現する〜ローコードによるWebアプリのバックエンド実装 #CNDF2023
acquiajp
0
410
DrupalCon Pittsburgh 2023 総まとめウェビナー
acquiajp
0
110
Acquia製品概要&Site Studioデモのご紹介
acquiajp
0
150
Other Decks in Programming
See All in Programming
C#の現在地 進化の歴史と、AI時代の.NET Everywhere
neuecc
5
4.9k
難しいけど、読めた。- OSSの入口に立った話。
sts11142
0
140
Starting & Sustaining Code-Based E2E Testing for Non-Coding QA Teams( #jasstniigata )
teyamagu
PRO
1
910
[2026-09-26]空論ジェネリックプロセス~テスト資産とAIで紡ぐ、再現可能なパフォーマンスチューニングの話~
tosite
0
250
更なる可用性を求めて、5年間運用したKotlinのアプリケーションをGoでリプレイスする話
ken_tunc
0
440
GitHubハンズオン講座 — 実務レベルのチーム開発のフローを身につけよう
junhat6
0
120
テストを司るデーモンに会いに行く 〜隔離した仮想マシンでテストを通すまで〜
h1d3mun3
1
620
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
Augmenting AI with the Power of Jakarta EE
ivargrimstad
0
440
すこし踏み込む CancellationToken
htkym
2
1.6k
Simple Storage Service(S3) is not simple
iwatsukayura
0
190
Embedded Swiftで作る自作USBデバイス によるiOSデバイスの自動テスト / iOSDC Japan 2026 glassfiber
glassfiber
0
290
Featured
See All Featured
Into the Great Unknown - MozCon
thekraken
41
2.8k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.7k
XXLCSS - How to scale CSS and keep your sanity
sugarenia
250
1.3M
A Modern Web Designer's Workflow
chriscoyier
699
190k
Building Applications with DynamoDB
mza
96
7.2k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
6
1.2k
The agentic SEO stack - context over prompts
schlessera
0
960
Avoiding the “Bad Training, Faster” Trap in the Age of AI
tmiket
0
260
10 Git Anti Patterns You Should be Aware of
lemiorhan
PRO
659
62k
HTML-Aware ERB: The Path to Reactive Rendering @ RubyCon 2026, Rimini, Italy
marcoroth
5
770
How GitHub (no longer) Works
holman
316
150k
Transcript
ୈ7ճ ςʔϚઃఆͷΧελϚΠζ Drupal ςʔϚ ։ൃೖߨ࠲
Drupal ςʔϚ։ൃೖߨ࠲γϦʔζ – Drupalʹ͓͚ΔʮςʔϚʯͱɺWebαΠτͷݟͨΛ୲͏ػೳͰ͢ɻຊΣϏφʔγϦʔ ζͰɺDrupalͷςʔϚ։ൃʹؔ͢ΔجૅࣝΛղઆ͠·͢ɻ – DrupalͷϑϩϯτΤϯυपΓʹ͍ͭͯମܥతʹֶͼ͍ͨํɺࣗͰΧελϜςʔϚΛ࡞Ε ΔΑ͏ʹͳΓ͍ͨํɺΞΫΠΞೝఆσϕϩούʔࢼݧΛࢦ͢ํʹ͓͢͢ΊͰ͢ɻ – DrupalΛҰ௨Γૢ࡞ͨ͜͠ͱ͕͋ΔํΛରͱ͍ͯ͠·͢ɻ·ͩDrupalΛ৮ͬͨ͜ͱ͕ແ
͍ํɺॳ৺ऀ͚DrupalνϡʔτϦΞϧಈըʢຊޠʣΛઌʹݟ͓ͯ͘ͱΑΓཧղ͕ਂ ·Γ·͢ɻ
1. ςʔϚݻ༗ͷઃఆ 2. ςʔϚઃఆΛΧελϚΠζ͢Δ 3. ςʔϚͷઃఆΛ༻͢Δ 4. ςʔϚΠϯετʔϧ࣌ʹॳظΛηοτ͢Δ 5. ࿅श
ΞδΣϯμ
ςʔϚݻ༗ͷઃఆ
– ςʔϚͷΠϯετʔϧ – ςʔϚͷΞϯΠϯετʔϧ – σϑΥϧτςʔϚͷΓସ͑ – ৽͍͠ςʔϚͷՃ ʢUpdate
ManagerϞδϡʔϧͰఏڙʣ ※ςʔϚͷՃϞδϡʔϧಉ༷ɺcomposerͰߦ͏ํ๏͕ਪ ͞Ε͍ͯ·͢ɻ – ݸʑͷςʔϚݻ༗ͷઃఆ ཧϝχϡʔʮςʔϚʯͰͰ͖Δ͜ͱ
ݸʑͷςʔϚݻ༗ͷઃఆ ηΫγϣϯλϒͷʮઃఆʯ(/admin/appearance/settings)͔Βɺ ֤ςʔϚ͝ͱʹݻ༗ͷઃఆ͕ߦ͑Δϖʔδ͕༻ҙ͞Ε͍ͯ·͢ɻ
σϑΥϧτͰ༻ҙ͞Ε͍ͯΔઃఆ߲ – ϖʔδཁૉͷදࣔͷઃఆ – ϩΰը૾ͷઃఆ – ͓ؾʹೖΓΞΠίϯͷઃఆ ʹؔͯ͠ɺΧελϜςʔϚଆ ͰԿ͠ͳͯ͘ɺσϑΥϧτ Ͱ༻ҙ͞Ε·͢ɻ
ίϯτϦϏϡʔτςʔϚͷςʔϚઃఆΛ͍ͯΈΑ͏ Bootstrap Barrioͷ߹ ςʔϚಠࣗͷઃఆ߲
ίϯτϦϏϡʔτςʔϚͷςʔϚઃఆΛ͍ͯΈΑ͏ W3CSSͷ߹ ςʔϚಠࣗͷઃఆ߲
ςʔϚઃఆͷΧελϚΠζ Drupal 8Ҏ߱Ͱɺ *.theme ϑΝΠϧ ·ͨ theme-settings.php ϑΝΠϧʹPHPؔΛՃ͢Δ͜ͱʹΑΓɺςʔϚઃఆͷϑΥʔϜ ΛมߋͰ͖·͢ɻ
ςʔϚઃఆΛΧελϚΠζ͢Δ
ςʔϚઃఆΛΧελϚΠζ͢Δํ๏ 1. ςʔϚσΟϨΫτϦʹ *.theme ϑΝΠϧ ͘͠ theme- settings.php ϑΝΠϧΛ༻ҙ͠·͢ɻ 2.
༻ҙͨ͠ϑΝΠϧͰ THEME_form_system_theme_settings_alterؔΛ࣮͠· ͢ɻ
<?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 ઃఆϖʔδʹςΩετ ϑΟʔϧυ͕Ճ͞Ε· ͢ɻ
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)
ԋश ΧελϜςʔϚͷઃఆϖʔδʹςΩετϑΟʔϧυΛ1ͭՃͯ͠Έ Α͏ – theme-settings.php ϑΝΠϧͷ࡞ – ؔͷ࣮ ԋशͰ༻͢ΔιʔείʔυGithubʹ͋Γ·͢ɻ https://github.com/hmaruyama/my-drupal9-theming/tree/vol7
ςʔϚͷઃఆΛ༻͢Δ
theme_get_settingؔ – ςʔϚͷPHPϑΝΠϧͰɺtheme_get_setting ؔΛݺͼग़͢͜ ͱͰϢʔβʔ͕ςʔϚઃఆϖʔδͰઃఆͨ͠ΛऔಘͰ͖·͢ɻ theme_get_setting('twitter_url');
TwigςϯϓϨʔτͰઃఆΛ༻͢Δ ઃఆΛςϯϓϨʔτϑΝΠϧʹ͢ʹɺϓϦϓϩηεؔͰɺtheme_get_settingؔΛ༻ͯ͠ઃ ఆΛऔಘ͠ɺvariablesྻʹೖ͠·͢ɻ function marucha_preprocess_page(&$variables) { $variables['twitter_url'] = theme_get_setting('twitter_url'); }
marucha.theme ͦ͏͢Δ͜ͱͰɺtwigϑΝΠϧͰ௨ৗͷTwigมͱಉ͡Α͏ʹΞΫηεͰ͖·͢ɻ <li><a href="{{ twitter_url }}" target="_blank">Twitter</a></li> page.html.twig
ԋश ઃఆΛTwigςϯϓϨʔτͰ༻ͯ͠ΈΑ͏ – *.themeϑΝΠϧʹϓϦϓϩηεؔΛ࣮ – TwigςϯϓϨʔτͷฤू ԋशͰ༻͢ΔιʔείʔυGithubʹ͋Γ·͢ɻ https://github.com/hmaruyama/my-drupal9-theming/tree/vol7
ςʔϚΠϯετʔϧ࣌ʹ ॳظΛηοτ͢Δ
ςʔϚʹॳظΛηοτ͢Δ – ςʔϚઃఆʹɺॳظΛઃఆ͢Δ͜ͱ͕ՄೳͰ͢ɻ – ςʔϚσΟϨΫτϦʹ config/install/*.settings.yml ϑΝΠϧΛ࡞͠ɺ͜ͷ தͰՃ͢ΔϑΥʔϜཁૉͷॳظΛΩʔόϦϡʔܗࣜͰηοτ͠·͢ɻ – ͜ͷॳظςʔϚͷΠϯετʔϧ࣌ʹө͞Ε·͢ɻ
logo: use_default: false # ςʔϚͷϩΰը૾Λ༻͠ͳ͍ twitter_url: 'https://twitter.com' # Twitter URLͷσϑΥϧτ config/install/marucha.settings.yml
ԋश ΧελϜςʔϚͷςʔϚઃఆʹॳظΛηοτͯ͠ΈΑ͏ – config/install/*.settings.yml ϑΝΠϧΛ࡞ – ςʔϚΛ࠶Πϯετʔϧͯ͠ɺॳظ͕ηοτ͞ΕΔ͔֬ೝ ԋशͰ༻͢ΔιʔείʔυGithubʹ͋Γ·͢ɻ https://github.com/hmaruyama/my-drupal9-theming/tree/vol7
࿅श
ΧελϜςʔϚͰςʔϚઃఆΛΧελϚΠζ͢ΔࡍʹɺͲͷϑΝΠϧʹϑοΫؔ Λهड़Ͱ͖·͔͢ʁ2ͭબ͍ͯͩ͘͠͞ɻ 1. *.theme 2. src/Form/SettigsForm.php 3. index.php 4. theme-settings.php
࿅श1
ΧελϜςʔϚͰςʔϚઃఆΛΧελϚΠζ͢ΔࡍʹɺͲͷϑΝΠϧʹϑοΫؔ Λهड़Ͱ͖·͔͢ʁ2ͭબ͍ͯͩ͘͠͞ɻ 1. *.theme 2. src/Form/SettigsForm.php 3. index.php 4. theme-settings.php
࿅श1 ਖ਼ղɿ1, 4
ςʔϚݻ༗ͷઃఆʹॳظΛ༻ҙ͢ΔࡍʹɺඞཁͳϑΝΠϧ࣍ͷ͏ͪͲΕ Ͱ͔͢ʁ 1. *.settings.yml 2. config/install/*.settings.yml 3. config/schema/*.schema.yml 4. theme-settings.php
5. *.theme ࿅श2
ςʔϚݻ༗ͷઃఆʹॳظΛ༻ҙ͢ΔࡍʹɺඞཁͳϑΝΠϧ࣍ͷ͏ͪͲΕ Ͱ͔͢ʁ 1. *.settings.yml 2. config/install/*.settings.yml 3. config/schema/*.schema.yml 4. theme-settings.php
5. *.theme ࿅श2 ਖ਼ղɿ2
ຊͷΞδΣϯμऴྃ
1. ςʔϚݻ༗ͷઃఆ 2. ςʔϚઃఆΛΧελϚΠζ͢Δ 3. ςʔϚͷઃఆΛ༻͢Δ 4. ςʔϚΠϯετʔϧ࣌ʹॳظΛηοτ͢Δ 5. ࿅श
ΞδΣϯμ
None