I have a custom block module. I want to override core/themes/bartik/templates/block.html.twig
in my-module
directory.
In my-module
directory I have a folder templates/
and the twig file block--my-module.html.twig
.
In modules/custom/my-module/my-module.module
i have:
function my_module_theme($existing, $type, $theme, $path) {
return array(
'my_module' => array(
'variables' => array('message' => NULL),
'template' => 'block--my-module'
),
);
}
If I insert in my build()
function in modules/custom/my-module/src/Plugin/Block/MyModule.php
e.g:
'#theme' => 'my_module',
my twig template is loaded from modules/custom/my-module/templates/block--my-module.html.twig
, but as a child inside the default block.html.twig core/themes/bartik/templates/block.html.twig
?
What I am doing wrong here?
function MYMODULE_theme_suggestions_block_alter(array &$suggestions, array $variables)
, but how exactly? – meez Oct 21 '18 at 7:23:-)
– leymannx Oct 21 '18 at 7:31{{ content['#test_var'] }}
– meez Oct 21 '18 at 8:58