Magento 2 (as well as Magento 1.x) supports layout directive action
, which intended to run an arbitrary public method of a block (the block is an object of class \Magento\Framework\View\Element\Template
or one of it descendants).
You can cnange block template by calling setTemplate
method:
<referenceBlock name='copyright'>
<action method='setTemplate'>
<argument name='template' xsi:type='string'>Dfr_Backend::page/copyright.phtml</argument>
</action>
</referenceBlock>
It works, but is regarded by the Magento core team as a legacy way.
Modern way:
<referenceBlock name='copyright'>
<arguments>
<argument
name='template'
xsi:type='string'
>Dfr_Backend::page/copyright.phtml</argument>
</arguments>
</referenceBlock>