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
Solved! Go to Solution.
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.
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.
Thanks, I completely missed that one