Warm tip: This article is reproduced from serverfault.com, please click

php-如何在另一个phtml文件中包含多个html文件?

(php - How to include multiple html file in another phtml file?)

发布于 2020-12-17 15:13:09

我想在Magento 2中将多个文件包含在一个phtml文件中。该项目最初在laravel中,看起来像这样:

https://i.imgur.com/XpUbynf.png

所以现在我需要将所有项目导入到Magento 2项目中,但是语义有所不同。到目前为止,我已经尝试过了,但是没有用:

https://i.imgur.com/hewweJg.png

我要调用的文件位于子文件夹中,这些文件的路径为:

Wo / EyeTest / view / frontend / templates / eyetestSteps

与其他子文件夹一样

Wo / EyeTest / view / frontend / templates / eyetestSteps / step1 /

Wo / EyeTest / view / frontend / templates / eyetestSteps / step2 /

你知道我该怎么做吗?当文件位于同一目录中时,没有问题,它可以显示,我想我写的路径不好。

谢谢

Questioner
Boscher Audrey
Viewed
0
Amit Saini 2020-12-23 03:00:50

请使用以下路径:

<?php echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Wo_EyeTest::eyetestSteps/step1/_instructions.phtml")->toHtml(); ?>