I have create a block which contains a phtml file.This .phtml file called other phtml file.
Please check code :
block name : ..\block\country.php
This block has a template file, name : country.phtml
Code in this file
<?php
echo $this->getLayout()->createBlock("Magento\Framework\View\Element\Template")->setTemplate("Namespace_Module::state.phtml")->toHtml();
?>
As you seen country.phtml
file call state.phtml
file.
Now issue is, if I want to use any function of parent block country.php
in state.phtml
file then I am getting an error.
So please help me how can I called functions of parent block country.php
Thank you.
If I set state.phtml
in country.phtml
like
<?php
echo $this->getLayout()->createBlock("Namespace\Module\Block\Country")->setTemplate("Namespace_Module::state.phtml")->toHtml();
?>
Then Is it possible to call functions of Country.php
in State.phtml
file ?