I'm using an index.php file under /pub/custom folder, which is used to create custom designs.
This file is completely written in html and javascript.
Is there any way to include current theme header and footer to this file?
For eg: https://example.com/custom/
should include the header and footer from https://example.com
There are so many answers for Magento 1, but I couldn't find anything for Magento 2.
I'm using version 2.1.15. and Porto theme.
Any help would be appreciated! Thanks.
Best Answer
First Download Module :-cadence/m2external
Click on this link:- https://github.com/cadencelabs/m2external
This module is use for loading store layout / blocks in an external file or program. it's help you access a specific container or block in your Magento 2 theme from an external system.
This module adds a new layout file external.xml.
You can copy the template file into app/design/frontned/VandorName/ThemeName/Magento_Theme/layout/external.xml
Once it’s there, you can customize the file to add any extra blocks not included in the default layout.
And after that you can create an External PHP file to call Custome Blocks , ReferenceContainer , ReferenceBlock in it.
external.xml
Now you create an External PHP file which call your Magento Header Footer.
In this file Absolute Path of Your Magento 2 Install directory are Used
Filename.php
This is a Source link click here
I Hope It's Helps You.