Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magento 2 - How to override block template

I try to override

vendor\magento\module-multishipping\view\frontend\templates\checkout\addresses.phtml

I create the layout

app\code\My\CustomModule\view\frontend\layout\multishipping_checkout_addresses.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <block class="Magento\Multishipping\Block\Checkout\Addresses" name="checkout_addresses" template="My_CustomModule::checkout/addresses.phtml" cacheable="false">
            </block>
        </referenceContainer>
    </body>
</page>

And the template

app\code\My\CustomModule\view\frontend\templates\checkout\addresses.phtml

<h1>It works </h1>

It doesn't work... Please help me! Thanks.

like image 985
ViSuaL Avatar asked Feb 08 '16 13:02

ViSuaL


2 Answers

<referenceBlock name='copyright'>
    <action method='setTemplate'>
        <argument name='template' xsi:type='string'>Dfr_Backend::page/copyright.phtml</argument>
    </action>
</referenceBlock>
like image 138
Dmitry Fedyuk Avatar answered Oct 01 '22 17:10

Dmitry Fedyuk


The <action> instruction is deprecated. You can also use:

<referenceBlock name="form.subscribe" template="{Vendor_Module}::newsletter/subscribe.phtml" />
like image 42
Altravista Avatar answered Oct 01 '22 18:10

Altravista