首页>Magento>source

我安装了magento 2& 工作正常.我在 app/design/frontend/vendor/theme/Magento_Theme/layout/default.xml有一个文件

来自顶级参考 <referenceContainer name="page.top">   我复制了这个块:

<block class="Magento\Framework\View\Element\Template" name="store.menu" group="navigation-sections" template="Magento_Theme::html/container.phtml">
    <arguments>
        <argument name="title" translate="true" xsi:type="string">Menu</argument>
    </arguments>
</block>

用于显示顶级菜单& 粘贴在新引用中(创建新引用):

<referenceContainer name="sidebar.main">
    <block class="Magento\Framework\View\Element\Template" name="store.menu" group="navigation-sections" template="Magento_Theme::html/container.phtml">
        <arguments>
            <argument name="title" translate="true" xsi:type="string">Menu</argument>
        </arguments>
    </block>
</referenceContainer>

所以整个文件看起来像这样:

<?xml version="1.0"?>
<!--
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
-->
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="header.container">
            <container name="header.panel.wrapper" htmlClass="panel wrapper" htmlTag="div" before="-"/>
        </referenceContainer>
        <move element="header.panel" destination="header.panel.wrapper"/>
        <move element="top.links" destination="header.panel" after="-"/>
        <move element="catalog.topnav" destination="store.menu" before="-"/>
        <referenceContainer name="page.top">
            <block class="Magento\Framework\View\Element\Template" name="navigation.sections" before="-" template="Magento_Theme::html/sections.phtml">
                <arguments>
                    <argument name="group_name" xsi:type="string">navigation-sections</argument>
                    <argument name="group_css" xsi:type="string">nav-sections</argument>
                </arguments>
                <block class="Magento\Framework\View\Element\Template" name="store.menu" group="navigation-sections" template="Magento_Theme::html/container.phtml">
                    <arguments>
                        <argument name="title" translate="true" xsi:type="string">Menu</argument>
                    </arguments>
                </block>
                <block class="Magento\Framework\View\Element\Text" name="store.links" group="navigation-sections">
                    <arguments>
                        <argument name="title" translate="true" xsi:type="string">Account</argument>
                        <argument name="use_force" xsi:type="boolean">true</argument>
                        <argument name="text" xsi:type="string"><![CDATA[<!-- Account links -->]]></argument>
                    </arguments>
                </block>
                <block class="Magento\Framework\View\Element\Template" name="store.settings" group="navigation-sections" template="Magento_Theme::html/container.phtml">
                    <arguments>
                        <argument name="title" translate="true" xsi:type="string">Settings</argument>
                    </arguments>
                    <block class="Magento\Store\Block\Switcher" name="store.settings.language" template="switch/languages.phtml">
                        <arguments>
                            <argument name="id_modifier" xsi:type="string">nav</argument>
                        </arguments>
                    </block>
                    <block class="Magento\Directory\Block\Currency" name="store.settings.currency" before="store_language" template="currency.phtml">
                        <arguments>
                            <argument name="id_modifier" xsi:type="string">nav</argument>
                        </arguments>
                    </block>
                </block>
            </block>
        </referenceContainer>
        <referenceContainer name="sidebar.main">
            <block class="Magento\Framework\View\Element\Template" name="store.menu" group="navigation-sections" template="Magento_Theme::html/container.phtml">
                <arguments>
                    <argument name="title" translate="true" xsi:type="string">Menu</argument>
                </arguments>
            </block>
        </referenceContainer>
    </body>
</page>

现在问题是,当我进行上述更改时,顶部菜单出现在左侧栏中,但从顶部菜单,它变得消失.我不知道如何解决它.如果我更改了它的名称,那么它就不会出现,所以名称必须相同,即 store.menu

任何人都可以解释如何解决这个问题?

谢谢。

最新回答
  • 2019-12-5
    1 #

    首次安装Magento 2时,将使用1列布局显示主页.您应该进行自定义布局或修改2列布局以将catalog.topnav元素移动到侧边栏。

  • magento 1.9:获取所有特色产品系列
  • testing:Magento 2单元测试异常