I'm trying to create a module which adds a page, the controller works but I cannot render a twig template for it.
The page layout is displayed without the page I created and this warning is reported in the logs:
"Theme hook eu_calendar not found."
but I do have the hook defined
This is the controller:
class EuCalendarController extends ControllerBase {
public function index() {
return [
'#title' => 'my title',
'#theme' => 'eu_calendar',
'#description' => 'description test',
];
}
}
Module file:
function eu_calendar_theme($existing, $type, $theme, $path) {
return [
'eu_calendar' => [
'template' => 'index',
],
];
}
I also tried adding variables
like
function eu_calendar_theme($existing, $type, $theme, $path) {
return [
'eu_calendar' => [
'variables' => [
'test_var' => NULL,
],
'template' => 'index',
],
];
}
What am I missing here?
And do I need to configure anything with the regions, I want my module to be displayed in the content
region by default...
Any documentation or tutorial is also welcome, I read a bunch of them none of them is explaining the options and details.
/modules/eu_calendar/templates/index.html.twig
to be rendered so I thought 'template' => 'index' is about that...mymodule.theme
*facepalm* Just to clarify, it's supposed to be saved in themymodule.module
.