首页>Magento>source

如果我想在每个产品视图页面上的"添加到购物车"按钮后显示我的模板文件,但它会显示在页面底部的内容中?

<layout>
    <catalog_product_view>
        <reference name="content">
            <block type="test_example/example" name="product.example" after="product.info.addtocart" template="test/example/view.phtml"/>
        </reference>
    </catalog_product_view>
</layout>

我尝试过很多不同的 after="product.info.addtocart"   通过在文件中搜索布局块名称,但无论如何都会在页面底部显示所有内容。

最新回答
  • 2019-8-16
    1 #

    您可以直接将模板文件添加到 product.info.addtocart   块。

    <layout>
        <catalog_product_view>
            <reference name="product.info.addtocart">
                <block type="test_example/example" after="-" name="product.example" template="test/example/view.phtml"/>
            </reference>
        </catalog_product_view>
    </layout>
    

  • 2019-8-16
    2 #

    app/design/frontend/YourPackage/YourTheme/template/catalog/product/view/addtocart.phtml

    以及 addtocart之后的代码   按钮

    <?php echo $this->getLayout()->createBlock('test_example/example')->setTemplate('test/example/view.phtml')->toHtml(); ?>
    

  • magento2:大多数按类别查看的产品不起作用
  • magento2:Magento 2 StoreManagerInterface已存在于编译中的上下文对象中