對default.xml的任何更改都會破壞首頁佈局


1

Magento 2尚不成熟。在另一個網站的克隆版本上進行操作,並嘗試在此處對自定義主題首頁進行簡單的外觀更改:

app/design/frontend/Vendor/Theme/Magento_Theme/layout/default.xml

我進行的任何更改都會立即顯示,但頁面的無關部分會同時中斷。page-header中的大部分內容都消失了,並且出現了一個名為nav-sections的新div,其中包含我們所有的類別。

無論我如何更改default.xml,這些確切的更改都會發生-即使在字符串中添加字符也會導致它們。

我的直覺是這是工作流程的問題,我仍然不清楚Magento 2何時以及如何決定創建和提供pub/staticgeneratedvar/generated的文件。

我還應該注意,我正在生產模式中進行這些更改,並且運行deploy不能解決任何問題。

我在做什麼錯了?

0

I think that you have removed some properties from your custom default.xml or you have some errors on it please try this:

  1. Copy the original default.xml from the parent theme to the custom one.
  2. Clear the content folder of : pub/static, var/view_preprocessed, var/cache

  3. Launch this command : php bin/magento setup:static-content:deploy -f

  4. Check line by line the property who breaks you layout.


0

It's simple solution.

by default Magento 2 just join file so core file with your get compile to one.

Block and component with are initialize with the same name as core will dissapear (after copying to theme folder).

You need to replace name in: app/design/frontend/Vendor/Theme/Magento_Theme/layout/default.xml

Change name attribute only in: <block... or <container... References don't need to be fixed. Be sure that name is uniquely across system.

Example:

From: <block class="Magento\Theme\Block\Html\Title" name="page.main.title" template="Magento_Theme::html/title.phtml"/>

To:

<block class="Magento\Theme\Block\Html\Title" name="custom.page.main.title" template="Magento_Theme::html/title.phtml"/>

WARNING: This will create new block after existing one. If you need to replace then replace <block... to <referenceBlock... as described in http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/layouts/xml-instructions.html