Skip to content
Advertisement

How to include multiple html file in another phtml file?

I would like to include several file in Magento 2 in one phtml file. The project was in laravel at first and looks like this :

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

So now I need to import all the project in a Magento 2 project but the semantic is different. I have tried this so far but doesnt work :

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

The files I’m trying to call are in a subfolder and the path of these files is :

Wo/EyeTest/view/frontend/templates/eyetestSteps

with other subfolders like

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

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

Do you have any idea how can I do this ? When the file is in the same directory, there is no problem, it’s display, and I guess I’m writting the path badly.

Thanks

Advertisement

Answer

Please use the below path for this:

<?php echo $this->getLayout()->createBlock("MagentoFrameworkViewElementTemplate")->setTemplate("Wo_EyeTest::eyetestSteps/step1/_instructions.phtml")->toHtml(); ?>
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement