I have a project on D8 where I don't use any custom themes, I use default seven theme for everything because there is no need of any visual theming.
So My question: Is it possible to override theme template using module? without implementing theme at all?
I have a case where I want to add custom third party generated value in node's template.
This is what I have done:
Implemented custom template:
function MY_MODULE_theme($existing, $type, $theme, $path) {
return array(
'video_teaser' => [
'template' => 'video_teaser',
'variables' => NULL,
]
);
}
Implemented hook_theme_suggestions_alter:
function MY_MODULE_theme_suggestions_alter(array &$suggestions, array $variables, $hook) {
if(in_array('node__teaser', $suggestions)){
$suggestions[] = 'video_teaser';
}
}
And this, works, instead of default template, my video_teser
template is used.
BUT: I have a problem passing default node variables to my custom template, they aren't passed automatically and I couldn't find the way to do this using current approach.