简体   繁体   中英

Magento 2 - How to call a custom phtml file in another phtml file, xml layout, static block and cms page

My file is in app/design/frontent/vendor_name/theme/Magento_Theme/templates/html/test.phtml

How to call this files in another phtml file, xml layout, static block and cms page

Please Help

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')) ?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM