How To Create Theme in Magento 2
How To Create Theme in Magento 2
Tutorial:
HOW TO
CREATE THEME IN
MAGENTO 2 A publication of
Part 1
Whoever you are an extension or theme developer, you should spend time reading this
blog post because youll understand more about theme and template structure in
Magento 2.
I will divide this tutorial into 2 parts. The part one is about primary elements in Theme
package. Part 2 (that I will post next week) will reveal how to customize in Magento 2.
Elements
The fundamental elements in theme
package in Magento 2
+ Base layout is a default layout area of each module. Its not recommended to
edit in these layout files if its not your custom module.
Eg:
app/code/Magento/Checkout/view/frontend/layout/checkout_cart_item_render
ers.xml
__app/code/<Namespace>/<Module>|__/view|__/<area>|__/layout|
<layout_file1>.xml|<layout_file2>.xml
Theme Layout
+ Theme layouts is the theme outside the module, allowing customizing default
layout of module by reporting corresponding <Namespace>_<Module> in theme
folder
Eg:
app/design/frontend/Magento/blank/Magento_Checkout/layout/
To create a layout file, follow the rules:
+ Each layout file calls for one handle and others called
+ Name of layout file is the name of handle layout. Eg: checkout_cart_index
+ Layout file called is in layout folder
+ Eg:
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<update handle="page_one_column" />
<referenceContainer name="content">
<!-- ... -->
</referenceContainer>
</layout>
The order to read and process layout files is described as below:
+ If layout file belongs to different module, the order to run will be: independent
module, dependent module and then alphabetical order of file name.
+ If file belongs to the same module, the order will be alphabetical order of file
name
The steps to proceed layout of the system:
+ Read the group of all default layout files (base), including dependent ones
+ Determine the order of inherited or overwritten files
+ Add all expanded layout, replace layout in base, get in parent layout, replace
parent layout files which are overwritten by the child ones
Here is the model of processing layout
Here is the model of processing layout
blog.magestore.com
Download PDF File