1

I'm trying to add a custom customer account dashboard page but it keeps returning as a blank page

customer_account.xml:

    <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <head>
            <title>PixelPin Connect</title>
        </head>
        <body>
            <referenceBlock name="customer_account_navigation">
                <block class="Magento\Framework\View\Element\Html\Link\Current" name="customer-account-navigation-pixelpin" after="-">
                    <arguments>
                        <argument name="path" xsi:type="string">socialconnect/customer/index</argument>
                        <!--Also tried "socialconnect/customer-->
                        <argument translate="true" name="label" xsi:type="string">Pixelpin Connect</argument>
                    </arguments>
                </block>
            </referenceBlock>
        </body>
    </page>

socialconnect_customer_index.xml:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column"  xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <title>PixelPin Connect</title>
        <css src="Inchoo_SocialConnect::inchoo_socialconnect/css/styles.css"/>
    </head>
    <update handle="customer_account"/>
    <body>
        <referenceContainer name="content">
            <block class="Inchoo\SocialConnect\Block\Pixelpin\Account" name="inchoo_socialconnect_pixelpin_account" template="Inchoo_SocialConnect::account.phtml" cacheable="false"/>          
            <block class="Inchoo\SocialConnect\Block\Pixelpin\Button" name="inchoo_socialconnect_account_pixelpin_button" template="Inchoo_SocialConnect::button.phtml" cacheable="false"/>  
        </referenceContainer>
    </body>
</page>

index.php:

<?php
namespace Inchoo\SocialConnect\Controller\Customer;

class Index extends \Magento\Framework\App\Action\Action {

public function execute() {
        $this->_view->loadlayout();

        $this->_view->renderLayout();
    }
}

system.log error stack:

[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'header.panel.wrapper' element cannot be added as child to 'header.container', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'head.components' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'requirejs-config' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'translate-config' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'translate' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'js_cookies' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'global_notices' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'skip_to_content.target' element cannot be added as child to 'main.content', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'header-wrapper' element cannot be added as child to 'header.container', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'navigation.sections' element cannot be added as child to 'page.top', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'top.container' element cannot be added as child to 'page.top', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'breadcrumbs' element cannot be added as child to 'page.top', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'page.main.title' element cannot be added as child to 'columns.top', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'page.messages' element cannot be added as child to 'columns.top', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'content.top' element cannot be added as child to 'main', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'content' element cannot be added as child to 'main', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'content.aside' element cannot be added as child to 'main', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'content.bottom' element cannot be added as child to 'main', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'page.bottom' element cannot be added as child to 'page.bottom.container', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'footer' element cannot be added as child to 'footer-container', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'absolute_footer' element cannot be added as child to 'before.body.end', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'catalog.compare.sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'cookie_notices' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'sale.reorder.sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'google_analytics' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'logger' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'paypal.express-in-context.component' element cannot be added as child to 'after.body.start', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'wishlist_sidebar' element cannot be added as child to 'sidebar.additional', because the latter doesn't exist [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'header.panel.wrapper' tries to reorder itself towards '', but their parents are different: 'header.container' and '' respectively. [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'skip_to_content.target' tries to reorder itself towards '', but their parents are different: 'main.content' and '' respectively. [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'navigation.sections' tries to reorder itself towards '', but their parents are different: 'page.top' and '' respectively. [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: the 'cookie_notices' tries to reorder itself towards 'global_notices', but their parents are different: 'after.body.start' and '' respectively. [] []
[2016-11-18 14:13:30] main.CRITICAL: Broken reference: No element found with ID 'before.body.end'. [] []

etc/frontend/routes.xml:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
   <router id="standard">
       <route id="inchoo_socialconnect" frontName="socialconnect">
                <module name="Inchoo_SocialConnect"/>
        </route>
   </router>
</config>

2 Answers 2

1

Well, the logs indicate an issue with your layout file. So, I'd double-check that to ensure the file name is exactly correct, etc. As annoying as that is, it's how Magento 2 does it.

Also, could you perhaps be a little more specific about what you mean when you say "it keeps returning as a blank page"? Is that the customer dashboard, or your custom controller?

EDIT:

Since it's your custom controller that's coming back blank, here are a couple things you can try:

First, ensure that the system is actually finding your controller. The easiest way to do this is to insert this code into the beginning of your execute() method:

echo "I'm here!";
die();

If it is, then you should really analyze your layout file for errors. I noticed that you don't have an XML version declaration at the top of your files (<?xml version="1.0"?>) - it may not make a difference, but you can try to put it in and see if it helps.

ANOTHER EDIT:

The issue is with your routes.xml file. Magento uses the route id, not the frontName as the first part of a URL. This is counter-intuitive and I'm not sure why. In most cases, it makes sense to have them match, so change your file to this:

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:App/etc/routes.xsd">
   <router id="standard">
        <route id="socialconnect" frontName="socialconnect">
            <module name="Inchoo_SocialConnect"/>
        </route>
    </router>
</config>
9
  • it's my custom controller.
    – Callum
    Nov 18, 2016 at 14:59
  • they do have '<?xml version="1.0"?>' at the top of the files, i just left them out
    – Callum
    Nov 18, 2016 at 15:22
  • Hmm. Are you sure your controller is being hit?
    – tjons
    Nov 18, 2016 at 15:23
  • I'm checking right now
    – Callum
    Nov 18, 2016 at 15:23
  • Also, could you post your routes.xml file?
    – tjons
    Nov 18, 2016 at 15:24
0

tjons answer is not correct, in so far as Magento does not use the routeId as the first part of an URL. It uses the frontName as the first part of an URL, as advertised.

However the difference is when setting the page layout for such a route, Magento uses the routeId for the naming structure of the layout XMLs, not the frontName.

So if your routes.xml contains

<route id="inchoo_socialconnect" frontName="socialconnect">…</route>

then the layout XML needs to be named

inchoo_socialconnect_customer_index.xml

for example, instead of socialconnect_customer_index.xml.

The URL will still be socialconnect/customer/index.

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.