簡體   English   中英

Magento 2 - 如何在另一個phtml文件,xml布局,靜態塊和cms頁面中調用自定義phtml文件

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

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

如何在另一個phtml文件,xml布局,靜態塊和cms頁面中調用此文件

請幫忙

xml layout文件中

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

cms blocks and cms pages

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

在一個phtml文件中

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM