I have a couple paragraphs set up in my content type. I would like to overwrite the templates from my module (long story - we want to reuse this same set up across multiple sites if I get this to work).
I used the following hook in my module:
/**
* Implements hook_theme_registry_alter().
*/
function my_module_theme_registry_alter(&$theme_registry) {
$theme_registry['paragraph']['path'] = drupal_get_path('module', 'my_module') . '/templates/paragraph';
$theme_registry['paragraph']['template'] = 'paragraph';
}
In my module's templates/paragraph folder I have the following files:
paragraph.html.twig
paragraph--accordion.html.twig
paragraph--carousel.html.twig
Here is theme debug:
<!-- THEME HOOK: 'paragraph' -->
<!-- FILE NAME SUGGESTIONS:
* paragraph--accordion--default.html.twig
* paragraph--accordion.html.twig
x paragraph--default.html.twig
* paragraph.html.twig
-->
<!-- BEGIN OUTPUT from 'modules/contrib/bootstrap_paragraphs/templates/paragraph/paragraph.html.twig' -->
It seems to work but the problem is that paragraph--accordion and paragraph--carousel always use paragraph.html.twig. How can I have paragraph--accordion and paragraph--carousel use the templates that are in my module. If I place them in my theme's template folder they do render.