I am trying to add templates for the paragraph in a custom module, but it uses only the paragraph.html.twig template file.
paragraph--example-ch-hero-panel.html.twig is one of the suggested template files, which is the one I am using.
By default, The template should be taken from the paragraph, but it doesn't work in my case. I didn't implement hook_theme()
in a module for this because I am not passing any value to the templates.
I tried the following code, but I got an error.
function example_ch_hero_panel_theme() {
return [
'paragraph__example_ch_hero_panel' => [
'render element' => 'element',
'template' => 'paragraph--example-ch-hero-panel',
'base hook' => 'paragraph',
],
];
}
function example_ch_hero_panel_theme_registry_alter(&$theme_registry) {
$theme_registry['page']['path'] = drupal_get_path('module', 'example_ch_hero_panel') . '/templates';
}
It throws the following exception.
Twig\Error\LoaderError: Template "modules/custom/example_ch_hero_panel/templates/page.html.twig" is not defined. in Twig\Loader\ChainLoader->getCacheKey()
Can anyone tell me how to fix this issue?