php - Magento 2 - 如何覆盖 block 模板

标签 php magento2 magento-2.0

我尝试覆盖

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

我创建布局

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>

和模板

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

<h1>It works </h1>

它不起作用...请帮助我! 谢谢。

最佳答案

<referenceBlock name='copyright'>
    <action method='setTemplate'>
        <argument name='template' xsi:type='string'>Dfr_Backend::page/copyright.phtml</argument>
    </action>
</referenceBlock>

关于php - Magento 2 - 如何覆盖 block 模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35271324/

相关文章:

php - 将 php 项目从 fedora 移动到 windows wamp 错误

php - 如何将 CSS 样式表包含到 *included* PHP 文件中?

php - 网站内容如何存储?

magento - 产品未出现在 Magento2 子类别中

php - CSS 路径问题 magento 2 安装

paypal - 如何在 magento2 中禁用 Paypal Credit 支付方式?

php - 将 session 中保存的数组中的多行插入表中?

magento - 有没有办法使用前端 Controller 以编程方式更新 QTY?

mysql - 删除重复的行,但保留一个没有唯一列的行

magento - 如何在 magento 2.0 中添加/插入扩展?