====== Création d'un thème depuis zéro ======
Sources:
* [[https://www.drupal.org/docs/theming-drupal|Drupal Theming Guide]]
* [[https://blog.templatetoaster.com/create-drupal-theme-from-scratch/]]
===== Création du dossier =====
Nom du thème créé : **mytheme**
* Créer le dossier **/themes/custom/mytheme**
* Y créer l'arborescente suivante :
themes
custom
mytheme
css
style.css
js
main.js
templates
page.html.twig
mytheme.info.yml
mytheme.libraries.yml
===== Configuration du Thème =====
name: My Great Theme
description: This is my first theme project
type: theme
base theme: false
core_version_requirement: ^8 || ^9
regions:
header: Header
content: Content
footer: Footer
page_top: Page top
page_bottom: Page bottom
libraries:
- mytheme/global-css
**page_top** et **page_bottom** sont deux régions cachées,
on ne peut pas y placer de bloc, mais elles doivent exister.
Comme on déclare au moins une région, il faut les déclarer toutes,
y compris ces deux-ci.
===== Librairies =====
global-css:
version: VERSION
css:
theme:
css/elements.css: {}
css/layout.css: {}
css/print.css: { media: print }
js:
js/main.js: {}
dependencies:
- core/jquery
===== Structure des templates du core =====
x-- core/modules/system/templates/html.html.twig
|
|
|
|
|
|
|
| x-- core/modules/toolbar/templates/toolbar.html.twig
| |
| x--
|
| x-- core/modules/system/templates/off-canvas-page_wrapper.html.twig
| |
| | x-- core/modules/system/templates/page.html.twig
| | |
| | x--
| |
| x--
|
|
|
|
x--
===== Réécrire un template =====
{{page.content}}