This solution requires finding all instances where the blok is used and create as many xml files as handles in which it is used. If the block is used very often or you want to make sure each new usage will not require adding this kind of configuration you can do it using plugin.
Plugin usage. Declare your plugin either in etc/di.xml or etc/frontend/di.xml
And then create a class My\Module\Plugin\Block with content like
namespace My\Module\Plugin;
class Block
{
public function beforeToHtml(\Other\Module\Block $block)
{
$block->setTemplate('My_Module::path/to/my/file.phtml');
}
}
Using layout xml files like:
This solution requires finding all instances where the blok is used and create as many xml files as handles in which it is used. If the block is used very often or you want to make sure each new usage will not require adding this kind of configuration you can do it using plugin.
Plugin usage. Declare your plugin either in etc/di.xml or etc/frontend/di.xml
And then create a class
My\Module\Plugin\Block
with content like