Magento 2 Block没有添加

时间:2017-08-15 16:25:21

标签: magento2

Magento 2相关问题: header.phtml包含但但purchase.phtml没有,我们无法找到问题原因。此错误仅出现在我们的成功页面

<?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>
    	<referenceBlock name="head.additional">
		    <block class="Anowave\Ec\Block\Track" name="ec_header" as="ec_header" template="header.phtml" />
            <block class="Anowave\Ec\Block\Track" name="ec_purchase" as="ec_purchase" template="purchase.phtml" >
            	<block class="Anowave\Ec\Block\Track" name="ec_datalayer" as="ec_datalayer" template="datalayer.phtml" />
            	<block class="Anowave\Ec\Block\Track" name="ec_impressions" as="ec_impressions" template="impression.phtml" />
            	<block class="Anowave\Ec\Block\Track" name="ec_search" as="ec_search" template="search.phtml" />
            	<block class="Anowave\Ec\Block\Track" name="ec_detail" as="ec_detail" template="detail.phtml" />
            </block>
		</referenceBlock>
        <referenceContainer name="after.body.start">
        	<block class="Anowave\Ec\Block\Track" name="ec_noscript" as="ec_noscript" template="noscript.phtml" />
        </referenceContainer>
        <referenceContainer name="before.body.end">
        	<block class="Anowave\Ec\Block\Track" name="ec_events" as="ec_events" template="events.phtml" />
        	<block class="Anowave\Ec\Block\Track" name="ec_promotions" as="ec_promotions" template="promotions.phtml" />
            <block class="Anowave\Ec\Block\Track" name="ec_footer" as="ec_footer" template="footer.phtml" />
        </referenceContainer>
    </body>
</page>

1 个答案:

答案 0 :(得分:0)

您希望在模板中使用通话模板。尝试在purchase.phtml中插入以下代码:

include ($block->getTemplateFile('Anowave_ec::search.phtml'));