cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.2 extension layout xml file being ignored

SOLVED

Magento 2.2 extension layout xml file being ignored

I've written an extension for my website, however the layout xml file is not being processed. I have created the controller class and frontend route and can view the URL, however the contents of the layout file is being ignored.

 

The structure of the extension is below (within the app/code directory)

 

Blacklab/Merlin/Controller/Users/Index.php

<?php
/**
 * 
 */
namespace Blacklab\Merlin\Controller\Users;

use \Magento\Framework\Controller\ResultFactory;

class Index extends \Magento\Framework\App\Action\Action
{
	protected $storeManager;

	protected $resultPageFactory;

	public function __construct(
		\Magento\Framework\App\Action\Context $context,
		\Magento\Framework\View\Result\PageFactory $resultPageFactory,
		\Magento\Store\Model\StoreManagerInterface $storeManager
	) {
		$this->storeManager = $storeManager;
		$this->resultPageFactory = $resultPageFactory;

		parent::__construct($context);
	}

	public function execute()
	{
		$resultPage = $this->resultFactory->create(ResultFactory::TYPE_PAGE);
		if ($navigationBlock = $resultPage->getLayout()->getBlock('customer_account_navigation')) {
			$navigationBlock->setActive('accounts/users/index');
		}
//		var_dump($resultPage->getLayout());
//		if ($block = $resultPage->getLayout()->getBlock('review_customer_list')) {
//			$block->setRefererUrl($this->_redirect->getRefererUrl());
//		}
		$resultPage->getConfig()->getTitle()->set(__('Manage Users'));
		return $resultPage;
	}
}


Blacklab/Merlin/etc/frontend/routes.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
    <router id="standard">
        <route id="merlin_customers" frontName="accounts">
            <module name="Blacklab_Merlin" />
        </route>
    </router>
</config>

Blacklab/Merlin/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
    <module name="Blacklab_Merlin" setup_version="1.4.5">
        <sequence>
            <module name="Magento_Sales" />
            <module name="Magento_Customer"/>
        </sequence>

    </module>
</config>

Blacklab/Merlin/view/frontend/layout/accounts_users_index.xml

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <update handle="customer_account"/>
    <body>
        <referenceContainer name="content">
            <block class="Blacklab\Merlin\Block\Account\Users" name="account.users" cacheable="false" template="users/list.phtml"/>
        </referenceContainer>
    </body>
</page>

I'm not exactly sure why the layout file is being ignored

Tags (2)
2 REPLIES

Re: Magento 2.2 extension layout xml file being ignored

Hi @BlackLabDigital

 

Change Blacklab/Merlin/etc/frontend/routes.xml

 

route id and frontName should be same

 

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../lib/internal/Magento/Framework/App/etc/routes.xsd">
    <router id="standard">
        <route id="accounts" frontName="accounts">
            <module name="Blacklab_Merlin" />
        </route>
    </router>
</config>

Setup upgrade and try.

 

If Issue Solved, Click Kudos/Accept As solutions.

Re: Magento 2.2 extension layout xml file being ignored

Thanks, I completely missed that one Smiley Frustrated