When two layout files that reference the same Layout name come into a merge - it would seem to me that the design
folder always takes preference.
Folder Structure
code
[vendorNameSpace]
[vendorModule]
view
frontend
layout
-catalog_category_view.xml
design
frontend
[thirdPartyThemeVendor]
[themeName]
Magento_Catalog
-layout
-catalog_category_view.xml
Layout file
code/[vendorNameSpace]/[vendorModule]/view/frontend/layout/catalog_category_view.xml
Whereas this references template="category/desc_main_column.phtml"
within the code
:
<referenceContainer name="content">
<block class="vendorNameSpace\vendorModule\Block\Category\View"
name="category_desc_main_column"
template="category/desc_main_column.phtml"
before="category.products"/>
</referenceContainer>
Which, additionally - this is also references in the design folder - with the same .xml
.
design/frontend/[thirdPartyThemeVendor]/themeName/Magento_Catalog/view/frontend/catalog_category_view.xml
This also references category_desc_main_column
- but inherits from Magento core:
<referenceContainer name="content">
<block class="Magento\Catalog\Block\Category\View"
name="category_desc_main_column"
template="category/desc_main_column.phtml"
before="category.products"/>
</referenceContainer>
Now on compile - these two get merged. The design
folder's catalog_category_view.xml
gets authority as it seems to get added the merged .xml
last.
Regardless of how many other modules in code
reference name="category_desc_main_column"
.
So in my thinking; Code has module.xml
to allow sequencing of code dependencies. Although this wouldn't work as design
isn't a module per say.
module.xml
Namespacing in themes work differently; as Module require modules to sequence against, not themes.
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="vendorNameSpace_vendorModule" setup_version="1.0.0">
<sequence>
<!-- Reference the design namespace? -->
<module name="thirdPartyThemeVendor_Catalog" />
</sequence>
</module>
</config>
So in Magento 2, does design
referenced templates gets absolute authority on the say of a template in .xml
, regardless how many times it's been referenced in third party modules?