L’idée est de créer un template spécifique à notre nouveau thème pour afficher le logo du site. Ce template doit être manipulable en back-office via l’interface Réglages > Communs > Thèmes > Choisir son thème > Choisir son template de page > Propriétés générales.

Méthode développeur front-end (facile) :
Les fichiers qui vont jouer un rôle prépondérant :
|
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Templates/ |_ noSidebarPage.json |_ noSidebarPage.twig App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Blocks/ |_ xhtml-header-logo.twig App/Themes/Project/[Nom_de_votre_theme]/Assets/ |_ blocks-templates.json |_ plugin.json |
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Templates/noSidebarPage.json
|
{ "editableContent":{ "headerLogo" : { "id" : "headerLogo", "type" : "block", "name" : "Rbs_Website_XhtmlTemplate", "parameters" : { "fullyQualifiedTemplateName": "Project_Kidiliz:xhtml-header-logo.twig" } } } } |
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Templates/noSidebarPage.twig
|
<!doctype html> <html data-ng-app="RbsChangeApp"> <head> [...] </head> <body> <header id="header" class="document-header"> <!-- headerLogo --> </header> [...] </body> </html> |
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Blocks/xhtml-header-logo.twig
|
<div class="logo"> <a href="#"> <img class="img-responsive" src="Theme/Project/Kidiliz/img/logo-kidiliz.png" width="168" height="50" alt="{{ i18n('t.project.kidiliz.front.header_logo', ['ucf']) }}" /> </a> </div> |
App/Themes/Project/[Nom_de_votre_theme]/Assets/blocks-templates.json
|
{ "Rbs_Website_XhtmlTemplate": { "templates": { "Project_Kidiliz:xhtml-header-logo.twig": { "label": "t.project.kidiliz.admin.template_xhtml_header_logo", "parameters": {} } } } } |
App/Themes/Project/[Nom_de_votre_theme]/Assets/plugin.json
Toujours vérifier la présence de ce fichier dans votre plugin.
|
{ "type":"theme", "vendor":"Project", "name":"Kidiliz", "defaultLCID":"fr_FR" } |
Méthode dépréciée (à utiliser en dernier recours si votre bloc ne s’affiche pas en BO) :
Les fichiers qui vont jouer un rôle prépondérant :
…donc il y en a encore quelques autres, notamment les locales et la vue WYSIWYG back-office qu’il faudra également prendre en compte.
|
App/Modules/Project/[Nom_de_votre_module]/Blocks/ |_ Listeners.php |_ Update.php App/Modules/Project/[Nom_de_votre_module]/Setup/ |_ Install.php App/Modules/Project/[Nom_de_votre_module]/ |_ plugin.json |
|
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Templates/ |_ noSidebarPage.json |_ noSidebarPage.twig App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Blocks/ |_ xhtml-header-logo.twig App/Themes/Project/[Nom_de_votre_theme]/Assets/ |_ blocks-templates.json |_ plugin.json |
App/Modules/Project/[Nom_de_votre_module]/Blocks/Listeners.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
<?php namespace Project\Kidiliz\Blocks; use Change\Presentation\Blocks\Standard\UpdateBlockInformation; use Change\Presentation\Blocks\Standard\RegisterByBlockName; use Zend\EventManager\EventManagerInterface; use Zend\EventManager\ListenerAggregateInterface; /** * @name \Project\Kidiliz\Blocks\Listeners */ class Listeners implements ListenerAggregateInterface { /** * Attach one or more listeners * Implementors may add an optional $priority argument; the EventManager * implementation will pass this to the aggregate. * @param \Zend\EventManager\EventManagerInterface $events * @return void */ public function attach(\Zend\EventManager\EventManagerInterface $events) { new UpdateBlockInformation('Rbs_Website_XhtmlTemplate', $events, function($event) {(new Update())->onUpdateXhtmlTemplateInformation($event);}); } /** * Detach all previously attached listeners * @param \Zend\EventManager\EventManagerInterface $events * @return void */ public function detach(\Zend\EventManager\EventManagerInterface $events) { // TODO: Implement detach() method. } } |
App/Modules/Project/[Nom_de_votre_module]/Blocks/Update.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
<?php namespace Project\Kidiliz\Blocks; use Change\Presentation\Blocks\Event; /** * @name \Project\Kidiliz\Blocks\Update */ class Update { /** * @see \Rbs\Website\Blocks\XhtmlTemplateInformation * @param Event $event */ public function onUpdateXhtmlTemplateInformation(Event $event) { $information = $event->getParam('information'); if ($information instanceof \Change\Presentation\Blocks\Information) { $ucf = array('ucf'); $i18nManager = $event->getApplicationServices()->getI18nManager(); $documentManager = $event->getApplicationServices()->getDocumentManager(); $information->addTemplateInformation('Project_Kidiliz', 'xhtml-header-logo.twig') ->setLabel($i18nManager->trans('m.project.project.admin.template_xhtml_header_logo', $ucf)); } } } |
App/Modules/Project/[Nom_de_votre_module]/Setup/Install.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
<?php namespace Project\Kidiliz\Setup; /** * @name \Kidiliz\Kidiliz\Setup\Install */ class Install extends \Change\Plugins\InstallBase { /** * @param \Zend\EventManager\EventManagerInterface $events * @param \Change\Plugins\Plugin $plugin */ // public function attach($events, $plugin) // { // parent::attach($events, $plugin); // } /** * @param \Change\Plugins\Plugin $plugin */ // public function initialize($plugin) // { // } /** * @param \Change\Plugins\Plugin $plugin * @param \Change\Application $application * @param \Change\Configuration\EditableConfiguration $configuration * @throws \RuntimeException */ public function executeApplication($plugin, $application, $configuration) { $configuration->addPersistentEntry('Change/Events/BlockManager/Project_Kidiliz', '\Project\Kidiliz\Blocks\Listeners'); } /** * @param \Change\Plugins\Plugin $plugin * @param \Change\Services\ApplicationServices $applicationServices * @throws \RuntimeException */ // public function executeServices($plugin, $applicationServices) // { // } /** * @param \Change\Plugins\Plugin $plugin */ // public function finalize($plugin) // { // } } |
App/Modules/Project/[Nom_de_votre_module]/plugin.json
Toujours vérifier la présence de ce fichier dans votre plugin.
|
{ "type":"module", "vendor":"Project", "name":"Kidiliz" } |
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Templates/noSidebarPage.json
|
{ "editableContent":{ "headerLogo" : { "id" : "headerLogo", "type" : "block", "name" : "Rbs_Website_XhtmlTemplate", "parameters" : { "fullyQualifiedTemplateName": "Project_Kidiliz:xhtml-header-logo.twig" } } } } |
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Templates/noSidebarPage.twig
|
<!doctype html> <html data-ng-app="RbsChangeApp"> <head> [...] </head> <body> <header id="header" class="document-header"> <!-- headerLogo --> </header> [...] </body> </html> |
App/Themes/Project/[Nom_de_votre_theme]/Assets/Twig/Project_[Nom_de_votre_theme]/Blocks/xhtml-header-logo.twig
|
<div class="logo"> <a href="#"> <img class="img-responsive" src="Theme/Project/Kidiliz/img/logo-kidiliz.png" width="168" height="50" alt="{{ i18n('t.project.kidiliz.front.header_logo', ['ucf']) }}" /> </a> </div> |
App/Themes/Project/[Nom_de_votre_theme]/Assets/blocks-templates.json
|
{ "Rbs_Website_XhtmlTemplate": { "templates": { "Project_Kidiliz:xhtml-header-logo.twig": { "label": "t.project.kidiliz.admin.template_xhtml_header_logo", "parameters": {} } } } } |
App/Themes/Project/[Nom_de_votre_theme]/Assets/plugin.json
Toujours vérifier la présence de ce fichier dans votre plugin.
|
{ "type":"theme", "vendor":"Project", "name":"Kidiliz", "defaultLCID":"fr_FR" } |