2

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?

4

Use setTemplate()

protected function _construct()
{
    parent::_construct();
    $this->setTemplate("QaisarSatti_HelloWorld::helloworld.phtml");

}

Reference

  • This is automatic call when file is execute? – Dhaduk Mitesh Jul 20 '18 at 6:10
  • @DhadukMitesh yes it is. – Qaisar Satti Jul 20 '18 at 9:15
  • If I replace the $_template line with this function, then it is working same. Right? – Dhaduk Mitesh Jul 20 '18 at 9:16
  • @DhadukMitesh this function is used for showing the output so anything you write in this function will show as output. – Qaisar Satti Jul 20 '18 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 '18 at 7:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.