0

Jimit\Categorytree\registration.php

<?php
    \Magento\Framework\Component\ComponentRegistrar::register(
        \Magento\Framework\Component\ComponentRegistrar::MODULE,
        'Jimit_Categorytree',
        __DIR__
    );

Jimit\Categorytree\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="Jimit_Categorytree" setup_version="0.0.1"/>
</config>

Jimit\Categorytree\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="categorytree" frontName="categorytree">
            <module name="Jimit_Categorytree" />
        </route>
    </router>
</config>

Jimit\Categorytree\Controller\Index\Index.php

<?php

namespace Jimit\Categorytree\Controller\Index;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ResponseInterface;
use Magento\Framework\View\Result\PageFactory;

class Index extends Action {

    private $pageFactory;

    public function __construct(
        Context $context,
        PageFactory $pageFactory
    )
    {
        parent::__construct($context);
        $this->pageFactory = $pageFactory;
    }


    public function execute()
    {
        $page = $this->pageFactory->create();
        return $page;
    }
}

Jimit\Categorytree\Block\Categorytree.php

<?php

namespace Jimit\Categorytree\Block;

use Magento\Framework\View\Element\Template;

class Categorytree extends Template
{
    public function getText() {
        return "Category";
    }
}

Jimit\Categorytree\view\frontend\layout\categorytree_index_index.xml

<?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="Jimit\Categorytree\Block\Categorytree" name="categorytree" template="Jimit_Categorytree::categorytree.phtml" />
        </referenceContainer>
    </body>
</page>

Jimit\Categorytree\view\frontend\templates\categorytree.phtml

JIMIT Test 

URL: https://localhost/Magento-CE-2_3_3/categorytree/index/index

When I run URL in browser white blank screen showing, not getting any error while commands and also not in logs.

Can anyone help me to find an issue?

Note: I have debugged, both methods from the controller are calling.

Thanks

3
0

Have you hit this: php bin/magento setup:upgrade

Check if your module enable and disable after hitting above command.

Well, It's Working Now.

enter image description here

2
  • I have already run all commands but it's not working for me – Jimit Bhavsar May 16 '20 at 12:25
  • Do you need codebase? – D Singh May 16 '20 at 14:33
0

try this step by step

Jimit/Categorytree/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
    \Magento\Framework\Component\ComponentRegistrar::MODULE,
    'Jimit_Categorytree',
    __DIR__
);

Jimit/Categorytree/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="Jimit_Categorytree" setup_version="1.0.0"/>
</config>

Jimit/Categorytree/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="categorytree" id="categorytree">
            <module name="Jimit_Categorytree"/>
        </route>
    </router>
</config>

Jimit/Categorytree/Controller/Index/Index.php

<?php

namespace Jimit\Categorytree\Controller\Index;

use Magento\Framework\App\Action\Action;

class Index extends Action
{

    public function execute()
    {
        $this->_view->loadLayout();
        $this->_view->getLayout()->initMessages();
        $this->_view->renderLayout();
    }
}

Jimit/Categorytree/Block/Categorytree.php

<?php
namespace Jimit\Categorytree\Block;

use Magento\Framework\View\Element\Template;
use Magento\Framework\View\Element\Template\Context;

class Categorytree extends Template
{

    public function __construct(
        Context $context,
        array $data = []
    ) {
        parent::__construct($context, $data);
    }

    public function getText() {

        return "Category";
    }
}

Jimit/Categorytree/view/frontend/layout/categorytree_index_index.xml

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
  <update handle="customer_account"/>
  <body>
    <referenceContainer name="content">
            <block class="Jimit\Categorytree\Block\Categorytree" name="categorytree" template="Jimit_Categorytree::categorytree.phtml" />
    </referenceContainer>
  </body>
</page>

Jimit/Categorytree/view/frontend/templates/categorytree.phtml

 <?php
/**
 * @var Jimit\Categorytree\Block\Categorytree $block;
 */
 ?>
<h4><?= $block->getText(); ?></h4>

Run CLI commands

php bin/magento module:enable Jimit_Categorytree
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento setup:static-content:deploy -f
php bin/magento ca:cl
php bin/magento ca:fl
Set permission

URL: https://localhost/Magento-CE-2_3_3/categorytree/index/index

I hope this will help you..!

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.