Guida Temi e Layout
Ultimo aggiornamento: 2026-04-09
Scopo
Personalizzare aspetto e shell di public e game senza modificare il core.
Limite importante
L'area admin non supporta override strutturale via tema.
Struttura base
custom/themes/<theme-id>/
theme.json
views/
layouts/
app/layouts/
assets/
css/
js/
images/
fonts/
Manifest minimo (theme.json)
{
"id": "my-theme",
"name": "My Theme",
"version": "1.0.0",
"compat": { "core": ">=0.7.0 <1.0.0" },
"shell": {
"public_layout": "layouts/theme-public.twig",
"game_layout": "app/layouts/theme-game.twig"
},
"body_class": {
"shared": ["theme-my-theme", "theme-shell"],
"public": ["theme-public-surface"],
"game": ["theme-game-surface"]
},
"assets": {
"shared_css": ["css/shared.css"],
"shared_js": ["js/shared.js"],
"public_css": ["css/public.css"],
"public_js": ["js/public.js"],
"game_css": ["css/game.css"],
"game_js": ["js/game.js"]
}
}
Configurazione tema attivo
sys_configs.active_theme(precedenza più alta)APP.theme.active_themeinconfigs/app.php- fallback core (nessun tema attivo)
Funzioni Twig disponibili
theme_active()theme_id()theme_meta([key])theme_asset(path)theme_assets(channel)con channel:shared_css,shared_js,public_css,public_js,game_css,game_jstheme_body_classes()theme_shell(area, fallback)
Comportamento asset condivisi
theme_assets('public_css')caricashared_csse poipublic_csstheme_assets('game_css')caricashared_csse poigame_csstheme_assets('public_js')caricashared_jse poipublic_jstheme_assets('game_js')caricashared_jse poigame_js
Body classes automatiche
Il runtime aggiunge sempre al tag <body>:
theme-context-publicoppuretheme-context-gametheme-active+theme-<theme-id>quando un tema e attivo- classi opzionali da
body_class
body_class supporta:
- stringa singola:
"body_class": "theme-foo hero-shell" - array semplice:
"body_class": ["theme-foo", "hero-shell"] - oggetto per contesto: chiavi
shared,all,default,public,game
Override e fallback template
Ordine di lookup:
custom/themes/<active_theme>/viewscustom/views(fallback legacy)app/views(core)
Requisiti shell
I template shell dichiarati in theme.json devono:
- esistere in
views/ - terminare con
.twig - esporre almeno un blocco shell/content (
content,public_page_content,game_page_content,public_shell,game_shell) - (contract v1) estendere il layout core corrispondente:
public_layout->{% extends 'layouts/layout.twig' %}game_layout->{% extends 'app/layouts/layout.twig' %}
Validazione tema
Script CLI:
C:\xampp\php\php.exe scripts/php/themes-validate.php
Guardrail
- niente business logic nel tema;
- niente path traversal (
..) nei path tema; - non alterare i mount runtime di modali/offcanvas/toast;
- mantenere compatibilità con
module_assetsemodule_slot.