i have phtml file and i declare in theBlock\login.php
as $_template = "phtml path
,
its working fine but not for MEQP2 its giving WARNING | Property name $_template should not be prefixed with an underscore to indicate visibility;
when i remove the underscore with veriable of $template then magento view is not working. i already use the upgrade:setup
command but not working fine. then what i do?
1 Answer
Use setTemplate()
protected function _construct()
{
parent::_construct();
$this->setTemplate("QaisarSatti_HelloWorld::helloworld.phtml");
}
-
-
-
If I replace the $_template line with this function, then it is working same. Right? Jul 20, 2018 at 9:16
-
@DhadukMitesh this function is used for showing the output so anything you write in this function will show as output. Jul 20, 2018 at 9:22
-
@QaisarSatti, How you have understand that you have to use
protected function _tohtml() { $this->setTemplate("QaisarSatti_HelloWorld::helloworld.phtml"); return parent::_toHtml(); }
– Amit Bera ♦Nov 6, 2018 at 7:36