I'm adding a new page for my company, and that requires the use of a module. After some searching, I got the routes to function. However, the page doesn't seem to load the block/template as defined in my module_controller_action.xml file.

Module structure for as far as relevant:

-+ MyCompany
 -+ CustomRouter
  -+ Controller
   -+ Test
     - Test.php (Gets called as expected)
   - Router.php
  -- etc/...
  -+ view
   -+ frontend
    -+ layout
      - customrouter_test_test.xml
    -+ templates
      - configure_price_list.phtml

I'm using a block from Magento/Customer/Blocks/Account/Dashboard/Info. This block already has all that I need. I tried using an exact copy, but didn't notice any change.

My files: Test.php:

namespace MyCompany\CustomRouter\Controller\Test;

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

class Test extends \Magento\Framework\App\Action\Action
    protected $resultPageFactory;

     * @param Context $context
     * @param PageFactory $resultPageFactory
    public function __construct(
        Context $context,
        PageFactory $resultPageFactory
    ) {
        $this->resultPageFactory = $resultPageFactory;

    public function execute()
    { // This function gets called 100% when expected, so the problem isn't in the router
        $resultPage = $this->resultPageFactory->create();
        $resultPage->getConfig()->getTitle()->set(__('Configure Price List'));
        return $resultPage;


<?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" layout="1column">
        <referenceContainer name="content">
            <block class="Magento\Customer\Block\Account\Dashboard\Info" name="configure_price_list" template="configure_price_list.phtml" cacheable="false" />


// Made by (my name)

 <div class=configure-price-list>
    <p>Template Loaded</p>

The page loads, and the page title gets displayed as I set it in Test.php. However, none of the content displays, as if customrouter_test_test.xml does not exist. Is there anyone who can point me to the missing link here ?

(Did try to watch a number of tutorials, according to them, current setup should work.)

EDIT: After request, here's routes.xml:

<?xml version="1.0"?>

<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="customrouter" frontName="customrouter">
            <module name="MyCompany_CustomRouter" />

And at the risk of stating the obvious, I'm loading [domain]/customrouter/test/test. I'm also loading another url I redirected with a custom router, which looks exactly the same (just the page heading I set in Test.php).

EDIT 2: I might have found a solution. But I'm still working on what caused the problem. currently im file-for-file switching a working custom action to act exactly like mine.

  • did you run static:content:deploy and cache:flush commands? Also add $this->_view->loadLayout(); this line in your controller's execute method. – Abhishek Panchal Feb 8 '18 at 16:04
  • how does your router.xml file look like? The one from etc/frontend – Marius Feb 8 '18 at 16:16
  • @AbhishekPanchal I did now. While that additional line looks like it should do the trick (I was wondering along those lines), it didn't change anything. Page still loads with just the title.@Marius I'll edit it in now – Gloweye Feb 9 '18 at 7:52

"Answer" might not be truly valid here.

It turns out the problem was with the block I imported from outside. The block I imported was located at Magento\Customer\Block\Account\Dashboard\Info. I first copied it to my own module, with the exact same contents, and it still didn't work. I then stripped out half of the functionality (just deleted function that I thought I wasn't going to need), and it started working.

The block constructor's arguments is reduced to:

\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer,


\Magento\Framework\View\Element\Template\Context $context,
\Magento\Customer\Helper\Session\CurrentCustomer $currentCustomer,
\Magento\Newsletter\Model\SubscriberFactory $subscriberFactory,
\Magento\Customer\Helper\View $helperView,

And of course, I deleted everything those other arguments were required for. And it worked.

I still don't understand how or why, but this might help other people with similar problems.

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.