While working in Magento, theme developers need to override the layouts from the core modules. And then the developers using those themes may need to customize them according to their requirements.
Magento always recommends, to ensure stability and secure your customizations from being deleted during the upgrade, not change out-of-the-box module and theme layouts. To make the necessary changes, create extending and overriding layout files in your custom theme or module.
When multiple copies of the same layouts are available in a project, developers get confused about the layout's execution. So to understand how the layouts are being processed by the application, see the points below:
- Layouts from the module's base directory.
- Then layouts from the module's area directory.
- If the same layout is customized in multiple modules, then they are merged based on the sequence of modules in the app/etc/config.xml file.
- Then layouts from the theme's design/frontend/Namespace_Module/layout folder.
- And in the theme also we need to check the sequence of the inherited theme. For example, If you're seeking a layout catalog_product_view that isn't accessible in your current theme, look at its parent. If the layout is not in the parent theme, you should look into the grandparent theme.
The application merges all layouts after collecting them from various locations, and repetitive parts are overwritten by the most recent one based on the above priority.
NOTE: Layout files that belong to inactive modules or modules with disabled output are ignored.
After all the layout files are merged, the application validates them based on the mode.
- Developer mode: Syntax is validated in .xml and .xsd files, and .xml files are validated according to the xsd schema. If any validation fails, the hard failure with process halt occurs.
- Default & Production mode: Syntax is validated in .xml and .xsd files. If validation fails, errors are logged to the var/log directory without throwing an exception. The validation according to the xsd schema is not performed.
Comments
Post a Comment