0

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?

1 Answer 1

0

So in Magento 2, does design referenced templates gets absolute authority on the say of a template in .xml?

  • Yes when we talk about layout and there is custom theme available and in active state then first priority is always theme why because , because we are modifying the core layout.
  • I have faced same issue previously , where i found magento actually checks like layout coming from core files ? if no then its straight forward checks to custom theme where we have overrided layout and serve the request. if its still not there then its going to check to your custom module .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.