首页 文章

Magento 2 - 如何在另一个phtml文件,xml布局,静态块和cms页面中调用自定义phtml文件

提问于
浏览
2

我的文件位于app / design / frontent / vendor_name / theme / Magento_Theme / templates / html / test.phtml

如何在另一个phtml文件,xml布局,静态块和cms页面中调用此文件

请帮忙

1 回答

  • 12

    In xml layout file

    <block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/test.phtml"/>
    

    In cms blocks and cms pages

    {{block class="Magento\Framework\View\Element\Template" name="test_file" template="Magento_Theme::html/test.phtml"}}
    

    In a phtml file

    <?php include ($block->getTemplateFile('Magento_Theme::html/test.phtml')) ?>
    

相关问题