Templates are not working correctly

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite












I'm attempting to create my own module with a custom template however in my browser, I am unable to view the 'hello world' output.



Gregt/Hello/block - helloworld.php



<?php
namespace GregTHelloBlock;

class Helloworld extends MagentoFrameworkViewElementTemplate

public function getHelloWorldTxt()

return 'Hello world!';




Gregt/Hello/controller/index - index.php



<?php

namespace GregTHelloControllerIndex;

use MagentoFrameworkAppActionContext;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;

public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory)

$this->_resultPageFactory = $resultPageFactory;
parent::__construct($context);


public function execute()

$resultPage = $this->_resultPageFactory->create();
echo ("hello");
return $resultPage;




Gregt/Hello/VIEW/frontend/layout - helloworld_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/
Framewo rk/View/Layout/etc/page_configuration.xsd" layout="1column">
<body>
<referenceContainer name="content">
<block class="GregTHelloBlockHelloworld" name="helloworld"
template="GregT_Hello::helloworld.phtml" />
</referenceContainer>
</body>
</page>


Gregt/Hello/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 id="helloworld" frontName="helloworld">
<module name="GregT_Hello" />
</route>
</router>
</config>


Gregt/Hello/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="GregT_Hello" setup_version="1.0.0">
</module>
</config>


Gregt/Hello/view/frontend/templates - helloworld.phtml



<h1><?php echo $block->getHelloWorldTxt(); ?></h1>


Gregt/Hello - registration.php



<?php

MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'GregT_Hello',
__DIR__
);


enter image description here







share|improve this question






















  • try with this <h1><?php echo $block->getHelloWorldTxt(); ?></h1>
    – kunj
    Aug 14 at 9:00










  • Your layout file is at wrong place I have added the answer with the correct place and content.
    – kunj
    Aug 14 at 9:30










  • Hi, Greg, welcome. You don't need to add "SOLVED" to the question, and also don't need to tag the title (the tagging system will do that for you). I've posted an edit removing those elements from the title. The stackexchange system will mark the question as solved (the green checkmark on accepted answer) and also show the main tag automatically.
    – Mindwin
    Aug 14 at 13:10

















up vote
2
down vote

favorite












I'm attempting to create my own module with a custom template however in my browser, I am unable to view the 'hello world' output.



Gregt/Hello/block - helloworld.php



<?php
namespace GregTHelloBlock;

class Helloworld extends MagentoFrameworkViewElementTemplate

public function getHelloWorldTxt()

return 'Hello world!';




Gregt/Hello/controller/index - index.php



<?php

namespace GregTHelloControllerIndex;

use MagentoFrameworkAppActionContext;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;

public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory)

$this->_resultPageFactory = $resultPageFactory;
parent::__construct($context);


public function execute()

$resultPage = $this->_resultPageFactory->create();
echo ("hello");
return $resultPage;




Gregt/Hello/VIEW/frontend/layout - helloworld_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/
Framewo rk/View/Layout/etc/page_configuration.xsd" layout="1column">
<body>
<referenceContainer name="content">
<block class="GregTHelloBlockHelloworld" name="helloworld"
template="GregT_Hello::helloworld.phtml" />
</referenceContainer>
</body>
</page>


Gregt/Hello/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 id="helloworld" frontName="helloworld">
<module name="GregT_Hello" />
</route>
</router>
</config>


Gregt/Hello/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="GregT_Hello" setup_version="1.0.0">
</module>
</config>


Gregt/Hello/view/frontend/templates - helloworld.phtml



<h1><?php echo $block->getHelloWorldTxt(); ?></h1>


Gregt/Hello - registration.php



<?php

MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'GregT_Hello',
__DIR__
);


enter image description here







share|improve this question






















  • try with this <h1><?php echo $block->getHelloWorldTxt(); ?></h1>
    – kunj
    Aug 14 at 9:00










  • Your layout file is at wrong place I have added the answer with the correct place and content.
    – kunj
    Aug 14 at 9:30










  • Hi, Greg, welcome. You don't need to add "SOLVED" to the question, and also don't need to tag the title (the tagging system will do that for you). I've posted an edit removing those elements from the title. The stackexchange system will mark the question as solved (the green checkmark on accepted answer) and also show the main tag automatically.
    – Mindwin
    Aug 14 at 13:10













up vote
2
down vote

favorite









up vote
2
down vote

favorite











I'm attempting to create my own module with a custom template however in my browser, I am unable to view the 'hello world' output.



Gregt/Hello/block - helloworld.php



<?php
namespace GregTHelloBlock;

class Helloworld extends MagentoFrameworkViewElementTemplate

public function getHelloWorldTxt()

return 'Hello world!';




Gregt/Hello/controller/index - index.php



<?php

namespace GregTHelloControllerIndex;

use MagentoFrameworkAppActionContext;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;

public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory)

$this->_resultPageFactory = $resultPageFactory;
parent::__construct($context);


public function execute()

$resultPage = $this->_resultPageFactory->create();
echo ("hello");
return $resultPage;




Gregt/Hello/VIEW/frontend/layout - helloworld_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/
Framewo rk/View/Layout/etc/page_configuration.xsd" layout="1column">
<body>
<referenceContainer name="content">
<block class="GregTHelloBlockHelloworld" name="helloworld"
template="GregT_Hello::helloworld.phtml" />
</referenceContainer>
</body>
</page>


Gregt/Hello/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 id="helloworld" frontName="helloworld">
<module name="GregT_Hello" />
</route>
</router>
</config>


Gregt/Hello/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="GregT_Hello" setup_version="1.0.0">
</module>
</config>


Gregt/Hello/view/frontend/templates - helloworld.phtml



<h1><?php echo $block->getHelloWorldTxt(); ?></h1>


Gregt/Hello - registration.php



<?php

MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'GregT_Hello',
__DIR__
);


enter image description here







share|improve this question














I'm attempting to create my own module with a custom template however in my browser, I am unable to view the 'hello world' output.



Gregt/Hello/block - helloworld.php



<?php
namespace GregTHelloBlock;

class Helloworld extends MagentoFrameworkViewElementTemplate

public function getHelloWorldTxt()

return 'Hello world!';




Gregt/Hello/controller/index - index.php



<?php

namespace GregTHelloControllerIndex;

use MagentoFrameworkAppActionContext;

class Index extends MagentoFrameworkAppActionAction

protected $_resultPageFactory;

public function __construct(Context $context,
MagentoFrameworkViewResultPageFactory $resultPageFactory)

$this->_resultPageFactory = $resultPageFactory;
parent::__construct($context);


public function execute()

$resultPage = $this->_resultPageFactory->create();
echo ("hello");
return $resultPage;




Gregt/Hello/VIEW/frontend/layout - helloworld_index_index.xml



<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 

xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/
Framewo rk/View/Layout/etc/page_configuration.xsd" layout="1column">
<body>
<referenceContainer name="content">
<block class="GregTHelloBlockHelloworld" name="helloworld"
template="GregT_Hello::helloworld.phtml" />
</referenceContainer>
</body>
</page>


Gregt/Hello/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 id="helloworld" frontName="helloworld">
<module name="GregT_Hello" />
</route>
</router>
</config>


Gregt/Hello/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="GregT_Hello" setup_version="1.0.0">
</module>
</config>


Gregt/Hello/view/frontend/templates - helloworld.phtml



<h1><?php echo $block->getHelloWorldTxt(); ?></h1>


Gregt/Hello - registration.php



<?php

MagentoFrameworkComponentComponentRegistrar::register(
MagentoFrameworkComponentComponentRegistrar::MODULE,
'GregT_Hello',
__DIR__
);


enter image description here









share|improve this question













share|improve this question




share|improve this question








edited Aug 14 at 13:12









Mindwin

1031




1031










asked Aug 14 at 8:39









Greg Taylor

637




637











  • try with this <h1><?php echo $block->getHelloWorldTxt(); ?></h1>
    – kunj
    Aug 14 at 9:00










  • Your layout file is at wrong place I have added the answer with the correct place and content.
    – kunj
    Aug 14 at 9:30










  • Hi, Greg, welcome. You don't need to add "SOLVED" to the question, and also don't need to tag the title (the tagging system will do that for you). I've posted an edit removing those elements from the title. The stackexchange system will mark the question as solved (the green checkmark on accepted answer) and also show the main tag automatically.
    – Mindwin
    Aug 14 at 13:10

















  • try with this <h1><?php echo $block->getHelloWorldTxt(); ?></h1>
    – kunj
    Aug 14 at 9:00










  • Your layout file is at wrong place I have added the answer with the correct place and content.
    – kunj
    Aug 14 at 9:30










  • Hi, Greg, welcome. You don't need to add "SOLVED" to the question, and also don't need to tag the title (the tagging system will do that for you). I've posted an edit removing those elements from the title. The stackexchange system will mark the question as solved (the green checkmark on accepted answer) and also show the main tag automatically.
    – Mindwin
    Aug 14 at 13:10
















try with this <h1><?php echo $block->getHelloWorldTxt(); ?></h1>
– kunj
Aug 14 at 9:00




try with this <h1><?php echo $block->getHelloWorldTxt(); ?></h1>
– kunj
Aug 14 at 9:00












Your layout file is at wrong place I have added the answer with the correct place and content.
– kunj
Aug 14 at 9:30




Your layout file is at wrong place I have added the answer with the correct place and content.
– kunj
Aug 14 at 9:30












Hi, Greg, welcome. You don't need to add "SOLVED" to the question, and also don't need to tag the title (the tagging system will do that for you). I've posted an edit removing those elements from the title. The stackexchange system will mark the question as solved (the green checkmark on accepted answer) and also show the main tag automatically.
– Mindwin
Aug 14 at 13:10





Hi, Greg, welcome. You don't need to add "SOLVED" to the question, and also don't need to tag the title (the tagging system will do that for you). I've posted an edit removing those elements from the title. The stackexchange system will mark the question as solved (the green checkmark on accepted answer) and also show the main tag automatically.
– Mindwin
Aug 14 at 13:10











4 Answers
4






active

oldest

votes

















up vote
4
down vote



accepted










Check below solution, May be helpful to you.



You have created Gregt/Hello/controller/index - index.php
And Gregt/Hello/block - helloworld.php



Also layout file wrong, It should be Gregt/Hello/view/frontend/layout - helloworld_index_index.xml



folder name should be Controller not controller, Block not block. Please correct folder name and check.






share|improve this answer






















  • Changed all these but still isn't showing
    – Greg Taylor
    Aug 14 at 9:06










  • Also you should apply changes as per @Amit bera
    – Suresh Chikani
    Aug 14 at 9:18

















up vote
4
down vote













You did a small mistake



<?php echo $this->getHelloWorldTxt(); ?>


Should be



<?php echo $block->getHelloWorldTxt(); ?>


Also have to change



name="helloworld" 
template="helloworld.phtml"


to



name="helloworld" 
template="GregT_Hello::helloworld.phtml"





share|improve this answer




















  • I've done this but no change
    – Greg Taylor
    Aug 14 at 9:05

















up vote
3
down vote














  1. Controller path should be like this:



    app/code/Gregt/Hello/Controller/Index/Index.php 


  2. in execute() try to put inside return "Hello";


  3. Call this path : domaine.com/helloworld and see If you see Hello






share|improve this answer




















  • Hi, I'm now able to see Hello at the top of the page.
    – Greg Taylor
    Aug 14 at 8:55










  • Did you updated the files to Capitalize letters and refreshed th cache ?
    – Prince
    Aug 14 at 8:59











  • Yes but I don't think it is using the template and instead just echoing from index.php
    – Greg Taylor
    Aug 14 at 9:00










  • Yes I mean the controller files from app/code/Gregt/Hello/controller/index/index.php to app/code/Gregt/Hello/Controller/Index/Index.php
    – Prince
    Aug 14 at 9:02






  • 1




    yes I knew it, I told you in the previous comment (errors in your module including the controller and layout) but it was necessary to debug the controller before, the essential is that you have solved your problem, good luck :)
    – Prince
    Aug 14 at 9:38

















up vote
2
down vote













Your lyout file should be like this:



<?xml version="1.0"?>
<page 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="GregTHelloBlockHelloworld" name="helloworld"
template="GregT_Hello::helloworld.phtml" />
</referenceContainer>
</body>
</page>


And Place must be at app/code/GregT/Hello/view/frontend/layout/helloworld_index_index.xml






share|improve this answer




















    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',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    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%2f238291%2ftemplates-are-not-working-correctly%23new-answer', 'question_page');

    );

    Post as a guest






























    4 Answers
    4






    active

    oldest

    votes








    4 Answers
    4






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    4
    down vote



    accepted










    Check below solution, May be helpful to you.



    You have created Gregt/Hello/controller/index - index.php
    And Gregt/Hello/block - helloworld.php



    Also layout file wrong, It should be Gregt/Hello/view/frontend/layout - helloworld_index_index.xml



    folder name should be Controller not controller, Block not block. Please correct folder name and check.






    share|improve this answer






















    • Changed all these but still isn't showing
      – Greg Taylor
      Aug 14 at 9:06










    • Also you should apply changes as per @Amit bera
      – Suresh Chikani
      Aug 14 at 9:18














    up vote
    4
    down vote



    accepted










    Check below solution, May be helpful to you.



    You have created Gregt/Hello/controller/index - index.php
    And Gregt/Hello/block - helloworld.php



    Also layout file wrong, It should be Gregt/Hello/view/frontend/layout - helloworld_index_index.xml



    folder name should be Controller not controller, Block not block. Please correct folder name and check.






    share|improve this answer






















    • Changed all these but still isn't showing
      – Greg Taylor
      Aug 14 at 9:06










    • Also you should apply changes as per @Amit bera
      – Suresh Chikani
      Aug 14 at 9:18












    up vote
    4
    down vote



    accepted







    up vote
    4
    down vote



    accepted






    Check below solution, May be helpful to you.



    You have created Gregt/Hello/controller/index - index.php
    And Gregt/Hello/block - helloworld.php



    Also layout file wrong, It should be Gregt/Hello/view/frontend/layout - helloworld_index_index.xml



    folder name should be Controller not controller, Block not block. Please correct folder name and check.






    share|improve this answer














    Check below solution, May be helpful to you.



    You have created Gregt/Hello/controller/index - index.php
    And Gregt/Hello/block - helloworld.php



    Also layout file wrong, It should be Gregt/Hello/view/frontend/layout - helloworld_index_index.xml



    folder name should be Controller not controller, Block not block. Please correct folder name and check.







    share|improve this answer














    share|improve this answer



    share|improve this answer








    edited Aug 14 at 8:48

























    answered Aug 14 at 8:42









    Suresh Chikani

    9,08242564




    9,08242564











    • Changed all these but still isn't showing
      – Greg Taylor
      Aug 14 at 9:06










    • Also you should apply changes as per @Amit bera
      – Suresh Chikani
      Aug 14 at 9:18
















    • Changed all these but still isn't showing
      – Greg Taylor
      Aug 14 at 9:06










    • Also you should apply changes as per @Amit bera
      – Suresh Chikani
      Aug 14 at 9:18















    Changed all these but still isn't showing
    – Greg Taylor
    Aug 14 at 9:06




    Changed all these but still isn't showing
    – Greg Taylor
    Aug 14 at 9:06












    Also you should apply changes as per @Amit bera
    – Suresh Chikani
    Aug 14 at 9:18




    Also you should apply changes as per @Amit bera
    – Suresh Chikani
    Aug 14 at 9:18












    up vote
    4
    down vote













    You did a small mistake



    <?php echo $this->getHelloWorldTxt(); ?>


    Should be



    <?php echo $block->getHelloWorldTxt(); ?>


    Also have to change



    name="helloworld" 
    template="helloworld.phtml"


    to



    name="helloworld" 
    template="GregT_Hello::helloworld.phtml"





    share|improve this answer




















    • I've done this but no change
      – Greg Taylor
      Aug 14 at 9:05














    up vote
    4
    down vote













    You did a small mistake



    <?php echo $this->getHelloWorldTxt(); ?>


    Should be



    <?php echo $block->getHelloWorldTxt(); ?>


    Also have to change



    name="helloworld" 
    template="helloworld.phtml"


    to



    name="helloworld" 
    template="GregT_Hello::helloworld.phtml"





    share|improve this answer




















    • I've done this but no change
      – Greg Taylor
      Aug 14 at 9:05












    up vote
    4
    down vote










    up vote
    4
    down vote









    You did a small mistake



    <?php echo $this->getHelloWorldTxt(); ?>


    Should be



    <?php echo $block->getHelloWorldTxt(); ?>


    Also have to change



    name="helloworld" 
    template="helloworld.phtml"


    to



    name="helloworld" 
    template="GregT_Hello::helloworld.phtml"





    share|improve this answer












    You did a small mistake



    <?php echo $this->getHelloWorldTxt(); ?>


    Should be



    <?php echo $block->getHelloWorldTxt(); ?>


    Also have to change



    name="helloworld" 
    template="helloworld.phtml"


    to



    name="helloworld" 
    template="GregT_Hello::helloworld.phtml"






    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Aug 14 at 8:59









    Amit Bera♦

    53.6k1366156




    53.6k1366156











    • I've done this but no change
      – Greg Taylor
      Aug 14 at 9:05
















    • I've done this but no change
      – Greg Taylor
      Aug 14 at 9:05















    I've done this but no change
    – Greg Taylor
    Aug 14 at 9:05




    I've done this but no change
    – Greg Taylor
    Aug 14 at 9:05










    up vote
    3
    down vote














    1. Controller path should be like this:



      app/code/Gregt/Hello/Controller/Index/Index.php 


    2. in execute() try to put inside return "Hello";


    3. Call this path : domaine.com/helloworld and see If you see Hello






    share|improve this answer




















    • Hi, I'm now able to see Hello at the top of the page.
      – Greg Taylor
      Aug 14 at 8:55










    • Did you updated the files to Capitalize letters and refreshed th cache ?
      – Prince
      Aug 14 at 8:59











    • Yes but I don't think it is using the template and instead just echoing from index.php
      – Greg Taylor
      Aug 14 at 9:00










    • Yes I mean the controller files from app/code/Gregt/Hello/controller/index/index.php to app/code/Gregt/Hello/Controller/Index/Index.php
      – Prince
      Aug 14 at 9:02






    • 1




      yes I knew it, I told you in the previous comment (errors in your module including the controller and layout) but it was necessary to debug the controller before, the essential is that you have solved your problem, good luck :)
      – Prince
      Aug 14 at 9:38














    up vote
    3
    down vote














    1. Controller path should be like this:



      app/code/Gregt/Hello/Controller/Index/Index.php 


    2. in execute() try to put inside return "Hello";


    3. Call this path : domaine.com/helloworld and see If you see Hello






    share|improve this answer




















    • Hi, I'm now able to see Hello at the top of the page.
      – Greg Taylor
      Aug 14 at 8:55










    • Did you updated the files to Capitalize letters and refreshed th cache ?
      – Prince
      Aug 14 at 8:59











    • Yes but I don't think it is using the template and instead just echoing from index.php
      – Greg Taylor
      Aug 14 at 9:00










    • Yes I mean the controller files from app/code/Gregt/Hello/controller/index/index.php to app/code/Gregt/Hello/Controller/Index/Index.php
      – Prince
      Aug 14 at 9:02






    • 1




      yes I knew it, I told you in the previous comment (errors in your module including the controller and layout) but it was necessary to debug the controller before, the essential is that you have solved your problem, good luck :)
      – Prince
      Aug 14 at 9:38












    up vote
    3
    down vote










    up vote
    3
    down vote










    1. Controller path should be like this:



      app/code/Gregt/Hello/Controller/Index/Index.php 


    2. in execute() try to put inside return "Hello";


    3. Call this path : domaine.com/helloworld and see If you see Hello






    share|improve this answer













    1. Controller path should be like this:



      app/code/Gregt/Hello/Controller/Index/Index.php 


    2. in execute() try to put inside return "Hello";


    3. Call this path : domaine.com/helloworld and see If you see Hello







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Aug 14 at 8:48









    Prince

    6,0512932




    6,0512932











    • Hi, I'm now able to see Hello at the top of the page.
      – Greg Taylor
      Aug 14 at 8:55










    • Did you updated the files to Capitalize letters and refreshed th cache ?
      – Prince
      Aug 14 at 8:59











    • Yes but I don't think it is using the template and instead just echoing from index.php
      – Greg Taylor
      Aug 14 at 9:00










    • Yes I mean the controller files from app/code/Gregt/Hello/controller/index/index.php to app/code/Gregt/Hello/Controller/Index/Index.php
      – Prince
      Aug 14 at 9:02






    • 1




      yes I knew it, I told you in the previous comment (errors in your module including the controller and layout) but it was necessary to debug the controller before, the essential is that you have solved your problem, good luck :)
      – Prince
      Aug 14 at 9:38
















    • Hi, I'm now able to see Hello at the top of the page.
      – Greg Taylor
      Aug 14 at 8:55










    • Did you updated the files to Capitalize letters and refreshed th cache ?
      – Prince
      Aug 14 at 8:59











    • Yes but I don't think it is using the template and instead just echoing from index.php
      – Greg Taylor
      Aug 14 at 9:00










    • Yes I mean the controller files from app/code/Gregt/Hello/controller/index/index.php to app/code/Gregt/Hello/Controller/Index/Index.php
      – Prince
      Aug 14 at 9:02






    • 1




      yes I knew it, I told you in the previous comment (errors in your module including the controller and layout) but it was necessary to debug the controller before, the essential is that you have solved your problem, good luck :)
      – Prince
      Aug 14 at 9:38















    Hi, I'm now able to see Hello at the top of the page.
    – Greg Taylor
    Aug 14 at 8:55




    Hi, I'm now able to see Hello at the top of the page.
    – Greg Taylor
    Aug 14 at 8:55












    Did you updated the files to Capitalize letters and refreshed th cache ?
    – Prince
    Aug 14 at 8:59





    Did you updated the files to Capitalize letters and refreshed th cache ?
    – Prince
    Aug 14 at 8:59













    Yes but I don't think it is using the template and instead just echoing from index.php
    – Greg Taylor
    Aug 14 at 9:00




    Yes but I don't think it is using the template and instead just echoing from index.php
    – Greg Taylor
    Aug 14 at 9:00












    Yes I mean the controller files from app/code/Gregt/Hello/controller/index/index.php to app/code/Gregt/Hello/Controller/Index/Index.php
    – Prince
    Aug 14 at 9:02




    Yes I mean the controller files from app/code/Gregt/Hello/controller/index/index.php to app/code/Gregt/Hello/Controller/Index/Index.php
    – Prince
    Aug 14 at 9:02




    1




    1




    yes I knew it, I told you in the previous comment (errors in your module including the controller and layout) but it was necessary to debug the controller before, the essential is that you have solved your problem, good luck :)
    – Prince
    Aug 14 at 9:38




    yes I knew it, I told you in the previous comment (errors in your module including the controller and layout) but it was necessary to debug the controller before, the essential is that you have solved your problem, good luck :)
    – Prince
    Aug 14 at 9:38










    up vote
    2
    down vote













    Your lyout file should be like this:



    <?xml version="1.0"?>
    <page 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="GregTHelloBlockHelloworld" name="helloworld"
    template="GregT_Hello::helloworld.phtml" />
    </referenceContainer>
    </body>
    </page>


    And Place must be at app/code/GregT/Hello/view/frontend/layout/helloworld_index_index.xml






    share|improve this answer
























      up vote
      2
      down vote













      Your lyout file should be like this:



      <?xml version="1.0"?>
      <page 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="GregTHelloBlockHelloworld" name="helloworld"
      template="GregT_Hello::helloworld.phtml" />
      </referenceContainer>
      </body>
      </page>


      And Place must be at app/code/GregT/Hello/view/frontend/layout/helloworld_index_index.xml






      share|improve this answer






















        up vote
        2
        down vote










        up vote
        2
        down vote









        Your lyout file should be like this:



        <?xml version="1.0"?>
        <page 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="GregTHelloBlockHelloworld" name="helloworld"
        template="GregT_Hello::helloworld.phtml" />
        </referenceContainer>
        </body>
        </page>


        And Place must be at app/code/GregT/Hello/view/frontend/layout/helloworld_index_index.xml






        share|improve this answer












        Your lyout file should be like this:



        <?xml version="1.0"?>
        <page 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="GregTHelloBlockHelloworld" name="helloworld"
        template="GregT_Hello::helloworld.phtml" />
        </referenceContainer>
        </body>
        </page>


        And Place must be at app/code/GregT/Hello/view/frontend/layout/helloworld_index_index.xml







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Aug 14 at 9:29









        kunj

        2,3672420




        2,3672420



























             

            draft saved


            draft discarded















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f238291%2ftemplates-are-not-working-correctly%23new-answer', 'question_page');

            );

            Post as a guest













































































            Comments

            Popular posts from this blog

            What does second last employer means? [closed]

            Installing NextGIS Connect into QGIS 3?

            One-line joke