Страница навигации по пользовательскому аккаунту клиента возвращается пустой


Я пытаюсь добавить пользовательскую страницу панели мониторинга учетной записи клиента, но она продолжает возвращаться как пустая страница

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();
    }
}

Система.стек ошибок журнала:

[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>
 1
Author: Callum, 2016-11-18

2 answers

Ну, журналы указывают на проблему с вашим файлом макета. Поэтому я бы перепроверил это, чтобы убедиться, что имя файла точно указано правильно, и т. Д. Как бы это ни раздражало, именно так это делает Magento 2.

Кроме того, не могли бы вы, возможно, немного конкретнее объяснить, что вы имеете в виду, когда говорите "он продолжает возвращаться в виде пустой страницы"? Это панель мониторинга клиента или ваш пользовательский контроллер?

ИЗМЕНИТЬ:

Поскольку ваш пользовательский контроллер возвращается пустым, вот пара вещей вы можете попробовать:

Во-первых, убедитесь, что система действительно находит ваш контроллер. Самый простой способ сделать это - вставить этот код в начало вашего метода execute():

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

Если это так, то вам действительно следует проанализировать свой файл макета на наличие ошибок. Я заметил, что у вас нет объявления версии XML в верхней части ваших файлов (<?xml version="1.0"?>) - это может не иметь значения, но вы можете попробовать вставить его и посмотреть, поможет ли это.

ЕЩЕ ОДНО РЕДАКТИРОВАНИЕ:

Проблема заключается в ваш файл routes.xml. Magento использует идентификатор маршрута, а не имя пользователя в качестве первой части URL-адреса. Это противоречит интуиции, и я не уверен, почему. В большинстве случаев имеет смысл, чтобы они совпадали, поэтому измените свой файл на этот:

<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>
 1
Author: tjons, 2016-11-18 15:48:50

Ответ Tjons неверен, поскольку Magento не использует routeId в качестве первой части URL-адреса. Он использует frontName в качестве первой части URL-адреса, как было объявлено.

Однако разница заключается в том, что при настройке макета страницы для такого маршрута Magento использует routeId для структуры имен XML-файлов макета, а не frontName.

Так что, если ваш routes.xml содержит

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

Тогда XML-файл макета должен быть названный

inchoo_socialconnect_customer_index.xml

Например, вместо socialconnect_customer_index.xml.

URL-адрес по-прежнему будет socialconnect/customer/index.

 0
Author: fritzmg, 2018-09-14 14:12:04