Magento does not read phtml file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












1















I'm absolute newbie at magento2.



My code:




Block/Index.php




<?php
namespace VendorModuleBlock;
class Index extends MagentoFrameworkViewElementTemplate






Controller/Index.php




<?php
namespace VendorModuleControllerIndex;

class Index extends MagentoFrameworkAppActionAction

protected $_pageFactory;

public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $pageFactory)

$this->_pageFactory = $pageFactory;
return parent::__construct($context);


public function execute()

return $this->_pageFactory->create();





Vendor/Module/etc/frontend/routes.xml




<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route frontName="helloworld" id="helloworld">
<module name="Vendor_Module"/>
</route>
</router>
</config>



etc/module.xml




<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0">
</module>
</config>



Vendor/Module/view/frontend/template/index/index.phtml




<h2>Helloworld</h2>



Vendor/Module/view/layout/helloworld_index_index.xml




<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
<block class="VendorModuleBlockIndex" name="index.index" template="Vendor_Module::index/index.phtml"/>
</referenceContainer>
</page>


Unfortunately


Helloworld

is not displaying.
Any suggestions?








share|improve this question
























  • Can you send from which url are you trying to access page ? Also Vendor/Module/view/frontend/template/index.php file should be .phtml

    – user55548
    Feb 18 at 11:47






  • 1





    Where is the layout.xml it should be helloworld_index_index.xml

    – Prathap Gunasekaran
    Feb 18 at 11:49
















1















I'm absolute newbie at magento2.



My code:




Block/Index.php




<?php
namespace VendorModuleBlock;
class Index extends MagentoFrameworkViewElementTemplate






Controller/Index.php




<?php
namespace VendorModuleControllerIndex;

class Index extends MagentoFrameworkAppActionAction

protected $_pageFactory;

public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $pageFactory)

$this->_pageFactory = $pageFactory;
return parent::__construct($context);


public function execute()

return $this->_pageFactory->create();





Vendor/Module/etc/frontend/routes.xml




<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route frontName="helloworld" id="helloworld">
<module name="Vendor_Module"/>
</route>
</router>
</config>



etc/module.xml




<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0">
</module>
</config>



Vendor/Module/view/frontend/template/index/index.phtml




<h2>Helloworld</h2>



Vendor/Module/view/layout/helloworld_index_index.xml




<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
<block class="VendorModuleBlockIndex" name="index.index" template="Vendor_Module::index/index.phtml"/>
</referenceContainer>
</page>


Unfortunately


Helloworld

is not displaying.
Any suggestions?








share|improve this question
























  • Can you send from which url are you trying to access page ? Also Vendor/Module/view/frontend/template/index.php file should be .phtml

    – user55548
    Feb 18 at 11:47






  • 1





    Where is the layout.xml it should be helloworld_index_index.xml

    – Prathap Gunasekaran
    Feb 18 at 11:49














1












1








1








I'm absolute newbie at magento2.



My code:




Block/Index.php




<?php
namespace VendorModuleBlock;
class Index extends MagentoFrameworkViewElementTemplate






Controller/Index.php




<?php
namespace VendorModuleControllerIndex;

class Index extends MagentoFrameworkAppActionAction

protected $_pageFactory;

public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $pageFactory)

$this->_pageFactory = $pageFactory;
return parent::__construct($context);


public function execute()

return $this->_pageFactory->create();





Vendor/Module/etc/frontend/routes.xml




<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route frontName="helloworld" id="helloworld">
<module name="Vendor_Module"/>
</route>
</router>
</config>



etc/module.xml




<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0">
</module>
</config>



Vendor/Module/view/frontend/template/index/index.phtml




<h2>Helloworld</h2>



Vendor/Module/view/layout/helloworld_index_index.xml




<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
<block class="VendorModuleBlockIndex" name="index.index" template="Vendor_Module::index/index.phtml"/>
</referenceContainer>
</page>


Unfortunately


Helloworld

is not displaying.
Any suggestions?








share|improve this question
















I'm absolute newbie at magento2.



My code:




Block/Index.php




<?php
namespace VendorModuleBlock;
class Index extends MagentoFrameworkViewElementTemplate






Controller/Index.php




<?php
namespace VendorModuleControllerIndex;

class Index extends MagentoFrameworkAppActionAction

protected $_pageFactory;

public function __construct(
MagentoFrameworkAppActionContext $context,
MagentoFrameworkViewResultPageFactory $pageFactory)

$this->_pageFactory = $pageFactory;
return parent::__construct($context);


public function execute()

return $this->_pageFactory->create();





Vendor/Module/etc/frontend/routes.xml




<?xml version="1.0" ?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
<router id="standard">
<route frontName="helloworld" id="helloworld">
<module name="Vendor_Module"/>
</route>
</router>
</config>



etc/module.xml




<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Vendor_Module" setup_version="1.0.0">
</module>
</config>



Vendor/Module/view/frontend/template/index/index.phtml




<h2>Helloworld</h2>



Vendor/Module/view/layout/helloworld_index_index.xml




<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<referenceContainer name="content">
<block class="VendorModuleBlockIndex" name="index.index" template="Vendor_Module::index/index.phtml"/>
</referenceContainer>
</page>


Unfortunately


Helloworld

is not displaying.
Any suggestions?





magento2






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Feb 18 at 13:49









PЯINCƏ

8,29331143




8,29331143










asked Feb 18 at 11:42









RufusRufus

1255




1255












  • Can you send from which url are you trying to access page ? Also Vendor/Module/view/frontend/template/index.php file should be .phtml

    – user55548
    Feb 18 at 11:47






  • 1





    Where is the layout.xml it should be helloworld_index_index.xml

    – Prathap Gunasekaran
    Feb 18 at 11:49


















  • Can you send from which url are you trying to access page ? Also Vendor/Module/view/frontend/template/index.php file should be .phtml

    – user55548
    Feb 18 at 11:47






  • 1





    Where is the layout.xml it should be helloworld_index_index.xml

    – Prathap Gunasekaran
    Feb 18 at 11:49

















Can you send from which url are you trying to access page ? Also Vendor/Module/view/frontend/template/index.php file should be .phtml

– user55548
Feb 18 at 11:47





Can you send from which url are you trying to access page ? Also Vendor/Module/view/frontend/template/index.php file should be .phtml

– user55548
Feb 18 at 11:47




1




1





Where is the layout.xml it should be helloworld_index_index.xml

– Prathap Gunasekaran
Feb 18 at 11:49






Where is the layout.xml it should be helloworld_index_index.xml

– Prathap Gunasekaran
Feb 18 at 11:49











3 Answers
3






active

oldest

votes


















1














1/



Vendor/Module/view/frontend/templates/index/index.phtml



and not



Vendor/Module/view/frontend/template/index/index.phtml



note:



template in Magento 1



templates in Magento 2



2/



Vendor/Module/view/frontend/layout/helloworld_index_index.xml



and not



Vendor/Module/view/layout/helloworld_index_index.xml






share|improve this answer






























    1














    I found 2 mistakes in the code



    1. Vendor/Module/view/layout/helloworld_index_index.xml this should be in Vendor/Module/view/frontend/layout/helloworld_index_index.xml


    2. Vendor/Module/view/frontend/template/index/index.phtml file this should be Vendor/Module/view/frontend/templates/index/index.phtml


    Make above to changes and flush cache and then check






    share|improve this answer






























      1














      If you rename tha template file from index.php to index.phtml, move it to view/frontent/templates/index/ and add a layout xml file in view/frontend/layout/helloworld_index_index.xml your code should work.



      For example if you just want to output the content of your template in the content area, you can use the following xml layout:



      <?xml version="1.0" ?>
      <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
      <body>
      <referenceContainer name="content">
      <block class="MagentoFrameworkViewElementTemplate" name="index.index" template="Vendor_Module::index/index.phtml"/>
      </referenceContainer>
      </body>
      </page>


      For using your bock you need to replace MagentoFrameworkViewElementTemplate with VendorModuleBlockIndex in the layout xml.






      share|improve this answer

























      • I've done your suggested changes, but still no result and no errors as well... I have updated my code above.

        – Rufus
        Feb 18 at 12:42











      • please check if you have enabled layout caching, if yes you have to flush that cache. But it would be better to deactivate it

        – HelgeB
        Feb 18 at 12:55











      • There is a type in the template path, I updated my answer too - it must be "templates" not "template"

        – HelgeB
        Feb 18 at 13:59










      Your Answer








      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "479"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: false,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: null,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262248%2fmagento-does-not-read-phtml-file%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      1














      1/



      Vendor/Module/view/frontend/templates/index/index.phtml



      and not



      Vendor/Module/view/frontend/template/index/index.phtml



      note:



      template in Magento 1



      templates in Magento 2



      2/



      Vendor/Module/view/frontend/layout/helloworld_index_index.xml



      and not



      Vendor/Module/view/layout/helloworld_index_index.xml






      share|improve this answer



























        1














        1/



        Vendor/Module/view/frontend/templates/index/index.phtml



        and not



        Vendor/Module/view/frontend/template/index/index.phtml



        note:



        template in Magento 1



        templates in Magento 2



        2/



        Vendor/Module/view/frontend/layout/helloworld_index_index.xml



        and not



        Vendor/Module/view/layout/helloworld_index_index.xml






        share|improve this answer

























          1












          1








          1







          1/



          Vendor/Module/view/frontend/templates/index/index.phtml



          and not



          Vendor/Module/view/frontend/template/index/index.phtml



          note:



          template in Magento 1



          templates in Magento 2



          2/



          Vendor/Module/view/frontend/layout/helloworld_index_index.xml



          and not



          Vendor/Module/view/layout/helloworld_index_index.xml






          share|improve this answer













          1/



          Vendor/Module/view/frontend/templates/index/index.phtml



          and not



          Vendor/Module/view/frontend/template/index/index.phtml



          note:



          template in Magento 1



          templates in Magento 2



          2/



          Vendor/Module/view/frontend/layout/helloworld_index_index.xml



          and not



          Vendor/Module/view/layout/helloworld_index_index.xml







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Feb 18 at 13:27









          PЯINCƏPЯINCƏ

          8,29331143




          8,29331143























              1














              I found 2 mistakes in the code



              1. Vendor/Module/view/layout/helloworld_index_index.xml this should be in Vendor/Module/view/frontend/layout/helloworld_index_index.xml


              2. Vendor/Module/view/frontend/template/index/index.phtml file this should be Vendor/Module/view/frontend/templates/index/index.phtml


              Make above to changes and flush cache and then check






              share|improve this answer



























                1














                I found 2 mistakes in the code



                1. Vendor/Module/view/layout/helloworld_index_index.xml this should be in Vendor/Module/view/frontend/layout/helloworld_index_index.xml


                2. Vendor/Module/view/frontend/template/index/index.phtml file this should be Vendor/Module/view/frontend/templates/index/index.phtml


                Make above to changes and flush cache and then check






                share|improve this answer

























                  1












                  1








                  1







                  I found 2 mistakes in the code



                  1. Vendor/Module/view/layout/helloworld_index_index.xml this should be in Vendor/Module/view/frontend/layout/helloworld_index_index.xml


                  2. Vendor/Module/view/frontend/template/index/index.phtml file this should be Vendor/Module/view/frontend/templates/index/index.phtml


                  Make above to changes and flush cache and then check






                  share|improve this answer













                  I found 2 mistakes in the code



                  1. Vendor/Module/view/layout/helloworld_index_index.xml this should be in Vendor/Module/view/frontend/layout/helloworld_index_index.xml


                  2. Vendor/Module/view/frontend/template/index/index.phtml file this should be Vendor/Module/view/frontend/templates/index/index.phtml


                  Make above to changes and flush cache and then check







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Feb 18 at 13:15









                  PMBPMB

                  392220




                  392220





















                      1














                      If you rename tha template file from index.php to index.phtml, move it to view/frontent/templates/index/ and add a layout xml file in view/frontend/layout/helloworld_index_index.xml your code should work.



                      For example if you just want to output the content of your template in the content area, you can use the following xml layout:



                      <?xml version="1.0" ?>
                      <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
                      <body>
                      <referenceContainer name="content">
                      <block class="MagentoFrameworkViewElementTemplate" name="index.index" template="Vendor_Module::index/index.phtml"/>
                      </referenceContainer>
                      </body>
                      </page>


                      For using your bock you need to replace MagentoFrameworkViewElementTemplate with VendorModuleBlockIndex in the layout xml.






                      share|improve this answer

























                      • I've done your suggested changes, but still no result and no errors as well... I have updated my code above.

                        – Rufus
                        Feb 18 at 12:42











                      • please check if you have enabled layout caching, if yes you have to flush that cache. But it would be better to deactivate it

                        – HelgeB
                        Feb 18 at 12:55











                      • There is a type in the template path, I updated my answer too - it must be "templates" not "template"

                        – HelgeB
                        Feb 18 at 13:59















                      1














                      If you rename tha template file from index.php to index.phtml, move it to view/frontent/templates/index/ and add a layout xml file in view/frontend/layout/helloworld_index_index.xml your code should work.



                      For example if you just want to output the content of your template in the content area, you can use the following xml layout:



                      <?xml version="1.0" ?>
                      <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
                      <body>
                      <referenceContainer name="content">
                      <block class="MagentoFrameworkViewElementTemplate" name="index.index" template="Vendor_Module::index/index.phtml"/>
                      </referenceContainer>
                      </body>
                      </page>


                      For using your bock you need to replace MagentoFrameworkViewElementTemplate with VendorModuleBlockIndex in the layout xml.






                      share|improve this answer

























                      • I've done your suggested changes, but still no result and no errors as well... I have updated my code above.

                        – Rufus
                        Feb 18 at 12:42











                      • please check if you have enabled layout caching, if yes you have to flush that cache. But it would be better to deactivate it

                        – HelgeB
                        Feb 18 at 12:55











                      • There is a type in the template path, I updated my answer too - it must be "templates" not "template"

                        – HelgeB
                        Feb 18 at 13:59













                      1












                      1








                      1







                      If you rename tha template file from index.php to index.phtml, move it to view/frontent/templates/index/ and add a layout xml file in view/frontend/layout/helloworld_index_index.xml your code should work.



                      For example if you just want to output the content of your template in the content area, you can use the following xml layout:



                      <?xml version="1.0" ?>
                      <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
                      <body>
                      <referenceContainer name="content">
                      <block class="MagentoFrameworkViewElementTemplate" name="index.index" template="Vendor_Module::index/index.phtml"/>
                      </referenceContainer>
                      </body>
                      </page>


                      For using your bock you need to replace MagentoFrameworkViewElementTemplate with VendorModuleBlockIndex in the layout xml.






                      share|improve this answer















                      If you rename tha template file from index.php to index.phtml, move it to view/frontent/templates/index/ and add a layout xml file in view/frontend/layout/helloworld_index_index.xml your code should work.



                      For example if you just want to output the content of your template in the content area, you can use the following xml layout:



                      <?xml version="1.0" ?>
                      <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
                      <body>
                      <referenceContainer name="content">
                      <block class="MagentoFrameworkViewElementTemplate" name="index.index" template="Vendor_Module::index/index.phtml"/>
                      </referenceContainer>
                      </body>
                      </page>


                      For using your bock you need to replace MagentoFrameworkViewElementTemplate with VendorModuleBlockIndex in the layout xml.







                      share|improve this answer














                      share|improve this answer



                      share|improve this answer








                      edited Feb 18 at 13:58

























                      answered Feb 18 at 12:12









                      HelgeBHelgeB

                      2,3821319




                      2,3821319












                      • I've done your suggested changes, but still no result and no errors as well... I have updated my code above.

                        – Rufus
                        Feb 18 at 12:42











                      • please check if you have enabled layout caching, if yes you have to flush that cache. But it would be better to deactivate it

                        – HelgeB
                        Feb 18 at 12:55











                      • There is a type in the template path, I updated my answer too - it must be "templates" not "template"

                        – HelgeB
                        Feb 18 at 13:59

















                      • I've done your suggested changes, but still no result and no errors as well... I have updated my code above.

                        – Rufus
                        Feb 18 at 12:42











                      • please check if you have enabled layout caching, if yes you have to flush that cache. But it would be better to deactivate it

                        – HelgeB
                        Feb 18 at 12:55











                      • There is a type in the template path, I updated my answer too - it must be "templates" not "template"

                        – HelgeB
                        Feb 18 at 13:59
















                      I've done your suggested changes, but still no result and no errors as well... I have updated my code above.

                      – Rufus
                      Feb 18 at 12:42





                      I've done your suggested changes, but still no result and no errors as well... I have updated my code above.

                      – Rufus
                      Feb 18 at 12:42













                      please check if you have enabled layout caching, if yes you have to flush that cache. But it would be better to deactivate it

                      – HelgeB
                      Feb 18 at 12:55





                      please check if you have enabled layout caching, if yes you have to flush that cache. But it would be better to deactivate it

                      – HelgeB
                      Feb 18 at 12:55













                      There is a type in the template path, I updated my answer too - it must be "templates" not "template"

                      – HelgeB
                      Feb 18 at 13:59





                      There is a type in the template path, I updated my answer too - it must be "templates" not "template"

                      – HelgeB
                      Feb 18 at 13:59

















                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Magento Stack Exchange!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f262248%2fmagento-does-not-read-phtml-file%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown






                      Popular posts from this blog

                      How to check contact read email or not when send email to Individual?

                      Bahrain

                      Postfix configuration issue with fips on centos 7; mailgun relay