2

How do you debug a page in a custom module. or more to the point. How do you debug whether the xml is rending the correct page content.

I am trying to create a page in my custom module, I am able to create the page but its content is blank.

I believe that the problem relates to the xml because if I do a vardump on the controller it renders an output. this means that the problem relates to the xml output.

below are my files-- I would really appriate any advice on how I can go out debugging the problem.

=> Block :

namespace Lsg\Authunpw\Block;

class PostList extends \Magento\Framework\View\Element\Template
{

    public function __construct(
        \Magento\Framework\View\Element\Template\Context $context,

        array $data = []
    ) {
        parent::__construct($context, $data);
    //    $this->_postCollectionFactory = $postCollectionFactory;
    }

    public function getIdentities()
    {
        return [\Lsg\Authunpw\Model\Customer::CACHE_TAG . '_' . 'list'];
    }

}

Fronend xml :

Lsg\Authunpw\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="auths" frontName="auths">
            <module name="Lsg_Authunpw" />
        </route>
    </router>
</config>

Frontend view :

authunpw_index_index.xml

<?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">
    <body>
        <referenceContainer name="content">
            <block class="Lsg\Authunpw\Block\PostList" name="auths.list" template="Lsg_Authunpw::list.phtml" />
        </referenceContainer>
    </body>
</page>

1 Answer 1

2

Magento identifies the handler from the url. So if you have defined routes as auths and calling it from index method and action then your handler should be auths_index_index.xml

Rename your xml file from

authunpw_index_index.xml 

To

auths_index_index.xml 
1
  • thank you so much. i have been on this issue for a week now
    – theSeeker
    Jun 27, 2018 at 7:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.