1

I am new with Magento, I found that it's realy hard to do even for doing trivial thing.

I just try to follow this article https://www.mageplaza.com/magento-2-module-development/view-block-layout-template-magento-2.html but the block seems does not loaded.

Here is my routes.xml

enter image description here

Here is my controller

enter image description here

Here is my layout

enter image description here

<?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="Mageplaza\HelloWorld\Block\Display" name="helloworld_display" template="Mageplaza_HelloWorld::sayhello.phtml" />
    </referenceContainer>
</page>

Here is my phtml

enter image description here

This is my browser view

enter image description here

I have tried this in my Block but nothing was happened. enter image description here

1

Magento layout use id route's id attribute to detect layout handler. So, you should change your layout file name to helloworld_home_index_display.xml

  • You are right mate, thank you, you save my day! – Yusuf Ibrahim May 5 at 5:40

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.