SlideShare a Scribd company logo
The Essential
Tutorial:
HOW TO
CREATE THEME IN
MAGENTO 2 A publication of
Whoever you are an extension or theme developer, you should spend time reading this
blog post because you’ll 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.
Part 1
Elements
a. Theme structure in Magento 2
b. Layout
c. New language style – LESS
d. Mage_page element
The fundamental elements in theme
package in Magento 2
a. Theme structure in
Magento 2
MVC structure in Magento 2 is clearer than in Magento 1.x. Modules in
Magento 2 will also be added View element in the module folder structure.
Catalog module: app/code/Magento/Catalog/ is an example for you.
Please pay attention to View element which is in the same position with
Controller, Model. In the View folder, there are below elements:
We can see that the inside structure has 3 elements, in which base element is
moved out from <area>. The folder structure in <area> folder includes layout,
templates, web.
For example, frontend has 3 fundamental folders
+ Layout folder contains all the layout file of module (similar to layout file of
Magento 1.x which is contained in all layout folders of theme). The code of
these layouts, of course, have different structure. I will write in details in
the specific part for layout file below.
+ Template folder has all template.phtml file, which is file rendered into html
as we know in Magento 1.x, inside code is not very different, just php code
mixes with html code.
+ Web folder is a totally new folder in Magento 2. You can see the image in the
next slide
New Web folder in Magento 2
+ The folders: css – stylesheet, js, media –
images are grouped. It replaces for 3
folders: css, images, js in previous
skin/frontend/base/default. In other words,
in Magento 2, the old skin folder is
removed and divided into elements in each
module.
b. Layout
In Magento 2, each module has a default layout which can be overwritten and
expanded by another layout.
Eg: app/code/Magento/Catalog/view/frontend/layout/default.xml
Magento 2 separates layout files into particular handle
Handle declaration is nearly the same as the previous rule:
catalog_product_view – is a handle according to module and controller action
The definition for page we want to apply the layout is more specifically by
declaring
catalog_product_view_type_simple_id_128
Or we can call to include other handles
Here is the example about layout file position of
Catalog module:
Handle declaration is nearly the same as the previous rule:
catalog_product_view – is a handle according to module and controller action
The definition for page we want to apply the layout is more specifically by
declaring
catalog_product_view_type_simple_id_128
Or we can call to include other handles
Here is the example about layout file position of
Catalog module:
+ Base layout is a default layout area of each module. It’s not recommended to
edit in these layout files if it’s 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
Base 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/
Theme Layout
+ 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:
To create a layout file, follow the rules:
<layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<update handle="page_one_column" />
<referenceContainer name="content">
<!-- ... -->
</referenceContainer>
</layout>
+ 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 order to read and process layout files is described as below:
+ 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
The steps to proceed layout of the system:
Here is the model of processing layout
Here is the model of processing layout
Tip: Read this blog post to
see detailed explanation
+ Container: The area to distribute page
elements
Layout/Block Area
+ Block: the area where default block elements
of Magento are in container
Layout/Block Area
The sample of layout content
<container name="container.1" label="Container 1"
as="container_1" output="1" htmlTag="div"
htmlId="container-1"
htmlClass="container">
<block class="MagentoModuleBlockClass" name="block.1">
<container name="child.container" label="Child Container"
as="child">
<block type="MagentoModuleBlockClass" name="block.2">
</container>
<block class="MagentoModuleBlockClass"
name="block.3"/>
</container>
<container name="container.2" as="container_2"
htmlTag="div"
htmlId="container-2" htmlClass="container"/>
c. New language style -
LESS
LESS is added as higher-level than CSS. It is translated into CSS thanks to LESS
library in php. We’re still allowed to add CSS URL in the source to use directly.
Use via LESS:
The pre-process LESS language in Magento 2 is through library in
lib/internal/Magento/Css/PreProcesso
c. New language style -
LESS
LESS is added as higher-level than CSS. It is translated into CSS thanks to LESS
library in php. We’re still allowed to add CSS URL in the source to use directly.
Use via LESS:
The pre-process LESS language in Magento 2 is through library in
lib/internal/Magento/Css/PreProcesso
Tip: Want to know more about
LESS. Go to this tutorial and
find an example
The Mage_page element in the previous
Magento version is replaced by
Mangento_Theme module
d. Mage_page element
So, we’re done for the 1st part. Have any questions? Tell us
blog.magestore.com
Download PDF File
Visit Magestore Blog to
download pdf file of this
tutorial & update latest
tutorials about Magento 2
Download PDF File
Visit Magestore Blog to
download pdf file of this
tutorial & update latest
tutorials about Magento 2
Magestore Blog: How to Create
theme in Magento 2

More Related Content

What's hot

Magento 2 theming - knowledge sharing session by suman kc
Magento 2 theming - knowledge sharing session by suman kcMagento 2 theming - knowledge sharing session by suman kc
Magento 2 theming - knowledge sharing session by suman kc
Suman KC
 
How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]
M-Connect Media
 
Front End Development in Magento
Front End Development in MagentoFront End Development in Magento
Front End Development in Magento
Eric Landmann
 
Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2
Mathew Beane
 
12 Amazing Features of Magento 2
12 Amazing Features of Magento 212 Amazing Features of Magento 2
12 Amazing Features of Magento 2
Schogini Systems Pvt Ltd
 
Finding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeFinding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento Code
Ben Marks
 
MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2
Mathew Beane
 
How To Install Magento 2 (updated for the latest version)
How To Install Magento 2 (updated for the latest version)How To Install Magento 2 (updated for the latest version)
How To Install Magento 2 (updated for the latest version)
Magestore
 
Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento Version
Meet Magento Italy
 
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Joshua Warren
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhubMagento Dev
 
How to Install Magento Theme
How to Install Magento ThemeHow to Install Magento Theme
How to Install Magento Theme
M-Connect Media
 
Meet Magento Belarus - Sergey Ivashchenko
Meet Magento Belarus - Sergey IvashchenkoMeet Magento Belarus - Sergey Ivashchenko
Meet Magento Belarus - Sergey Ivashchenko
Amasty
 
Sergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions DistributionSergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions Distribution
Meet Magento Italy
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
Duke Dao
 
Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overview
Meet Magento Italy
 
Oleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceOleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performance
Meet Magento Italy
 
Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2
Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2
Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2
Meet Magento Italy
 
Magento2 what's new in theming
Magento2 what's new in themingMagento2 what's new in theming
Magento2 what's new in theming
Waruna Viraj Perera
 
How to Install Magento 2 On Wamp
How to Install Magento 2 On WampHow to Install Magento 2 On Wamp
How to Install Magento 2 On WampTecstub
 

What's hot (20)

Magento 2 theming - knowledge sharing session by suman kc
Magento 2 theming - knowledge sharing session by suman kcMagento 2 theming - knowledge sharing session by suman kc
Magento 2 theming - knowledge sharing session by suman kc
 
How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]How to Install Magento 2 [Latest Version]
How to Install Magento 2 [Latest Version]
 
Front End Development in Magento
Front End Development in MagentoFront End Development in Magento
Front End Development in Magento
 
Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2Madison PHP - Getting Started with Magento 2
Madison PHP - Getting Started with Magento 2
 
12 Amazing Features of Magento 2
12 Amazing Features of Magento 212 Amazing Features of Magento 2
12 Amazing Features of Magento 2
 
Finding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeFinding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento Code
 
MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2
 
How To Install Magento 2 (updated for the latest version)
How To Install Magento 2 (updated for the latest version)How To Install Magento 2 (updated for the latest version)
How To Install Magento 2 (updated for the latest version)
 
Federico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento VersionFederico Soich - Upgrading Magento Version
Federico Soich - Upgrading Magento Version
 
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
Magento 2 - An Intro to a Modern PHP-Based System - Northeast PHP 2015
 
Imagine recap-devhub
Imagine recap-devhubImagine recap-devhub
Imagine recap-devhub
 
How to Install Magento Theme
How to Install Magento ThemeHow to Install Magento Theme
How to Install Magento Theme
 
Meet Magento Belarus - Sergey Ivashchenko
Meet Magento Belarus - Sergey IvashchenkoMeet Magento Belarus - Sergey Ivashchenko
Meet Magento Belarus - Sergey Ivashchenko
 
Sergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions DistributionSergii Shymko: Magento 2: Composer for Extensions Distribution
Sergii Shymko: Magento 2: Composer for Extensions Distribution
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 Development
 
Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overview
 
Oleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performanceOleh Kobchenko - Configure Magento 2 to get maximum performance
Oleh Kobchenko - Configure Magento 2 to get maximum performance
 
Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2
Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2
Manuele Menozzi - Gestione delle dipendenze con Composer in Magento 2
 
Magento2 what's new in theming
Magento2 what's new in themingMagento2 what's new in theming
Magento2 what's new in theming
 
How to Install Magento 2 On Wamp
How to Install Magento 2 On WampHow to Install Magento 2 On Wamp
How to Install Magento 2 On Wamp
 

Viewers also liked

Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015
Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015
Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015
Joshua Warren
 
Magento 2 Admin Mobile App
Magento 2 Admin Mobile AppMagento 2 Admin Mobile App
Magento 2 Admin Mobile App
AppJetty
 
Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2
Meet Magento Italy
 
Outlook on Magento 2
Outlook on Magento 2Outlook on Magento 2
Outlook on Magento 2
Matthias Glitzner-Zeis
 
Meet Magento Belarus - Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus -  Magento2: What to expect and when? - Elena LeonovaMeet Magento Belarus -  Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus - Magento2: What to expect and when? - Elena Leonova
Elena Leonova
 
Getting your Hands Dirty Testing Magento 2 (at London Meetup)
Getting your Hands Dirty Testing Magento 2 (at London Meetup)Getting your Hands Dirty Testing Magento 2 (at London Meetup)
Getting your Hands Dirty Testing Magento 2 (at London Meetup)
vinaikopp
 
Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent
MeetMagentoNY2014
 
Magento 2 looks like.
Magento 2 looks like.Magento 2 looks like.
Magento 2 looks like.
Magestore
 

Viewers also liked (8)

Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015
Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015
Magento 2 - An Intro to a Modern PHP-Based System - ZendCon 2015
 
Magento 2 Admin Mobile App
Magento 2 Admin Mobile AppMagento 2 Admin Mobile App
Magento 2 Admin Mobile App
 
Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2Sergii Shymko - Code migration tool for upgrade to Magento 2
Sergii Shymko - Code migration tool for upgrade to Magento 2
 
Outlook on Magento 2
Outlook on Magento 2Outlook on Magento 2
Outlook on Magento 2
 
Meet Magento Belarus - Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus -  Magento2: What to expect and when? - Elena LeonovaMeet Magento Belarus -  Magento2: What to expect and when? - Elena Leonova
Meet Magento Belarus - Magento2: What to expect and when? - Elena Leonova
 
Getting your Hands Dirty Testing Magento 2 (at London Meetup)
Getting your Hands Dirty Testing Magento 2 (at London Meetup)Getting your Hands Dirty Testing Magento 2 (at London Meetup)
Getting your Hands Dirty Testing Magento 2 (at London Meetup)
 
Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent Magento 2 overview. Alan Kent
Magento 2 overview. Alan Kent
 
Magento 2 looks like.
Magento 2 looks like.Magento 2 looks like.
Magento 2 looks like.
 

Similar to How To Create Theme in Magento 2 - Part 1

How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0
MageWorld
 
How to-create-a-simple-module-in-magento-2.0
How to-create-a-simple-module-in-magento-2.0How to-create-a-simple-module-in-magento-2.0
How to-create-a-simple-module-in-magento-2.0
Daniele Crupi
 
Designing for magento
Designing for magentoDesigning for magento
Designing for magentohainutemicute
 
Magento mega menu extension
Magento mega menu extensionMagento mega menu extension
Magento mega menu extension
Bun Danny
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
Mage Guru
 
Magento2 frontend development
Magento2   frontend developmentMagento2   frontend development
Magento2 frontend development
Kapil Dev Singh
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentIvan Chepurnyi
 
Intro to OctoberCMS
Intro to OctoberCMSIntro to OctoberCMS
Intro to OctoberCMS
Kenton Spence
 
Magento2 Basics for Frontend Development
Magento2 Basics for Frontend DevelopmentMagento2 Basics for Frontend Development
Magento2 Basics for Frontend Development
Kapil Dev Singh
 
M2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookM2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookTrọng Huỳnh
 
Make implementation of third party elements in magento 2 in 5-times easier
Make implementation of third party elements in magento 2 in 5-times easierMake implementation of third party elements in magento 2 in 5-times easier
Make implementation of third party elements in magento 2 in 5-times easier
Elena Kulbich
 
Architecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling ToolArchitecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling ToolAdriaan Venter
 
Actionview
ActionviewActionview
Actionview
Amal Subhash
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentationsasidhar
 
Silverstripe 2.4-highlights-gpmd
Silverstripe 2.4-highlights-gpmdSilverstripe 2.4-highlights-gpmd
Silverstripe 2.4-highlights-gpmdGPMD Ltd
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction
Diego Scataglini
 
46h interaction 1.lesson Hello world
46h interaction 1.lesson Hello world46h interaction 1.lesson Hello world
46h interaction 1.lesson Hello world
hemi46h
 
Magento Theme from Development to Importance in 2022.pptx
Magento Theme from Development to Importance in 2022.pptxMagento Theme from Development to Importance in 2022.pptx
Magento Theme from Development to Importance in 2022.pptx
Agento Support
 

Similar to How To Create Theme in Magento 2 - Part 1 (20)

How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0How to create a simple module in Magento 2.0
How to create a simple module in Magento 2.0
 
How to-create-a-simple-module-in-magento-2.0
How to-create-a-simple-module-in-magento-2.0How to-create-a-simple-module-in-magento-2.0
How to-create-a-simple-module-in-magento-2.0
 
Designing for magento
Designing for magentoDesigning for magento
Designing for magento
 
Magento mega menu extension
Magento mega menu extensionMagento mega menu extension
Magento mega menu extension
 
Mageguru - magento custom module development
Mageguru -  magento custom module development Mageguru -  magento custom module development
Mageguru - magento custom module development
 
Magento2 frontend development
Magento2   frontend developmentMagento2   frontend development
Magento2 frontend development
 
Magento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module developmentMagento 2.0: Prepare yourself for a new way of module development
Magento 2.0: Prepare yourself for a new way of module development
 
Creating a basic joomla
Creating a basic joomlaCreating a basic joomla
Creating a basic joomla
 
Intro to OctoberCMS
Intro to OctoberCMSIntro to OctoberCMS
Intro to OctoberCMS
 
Magento2 Basics for Frontend Development
Magento2 Basics for Frontend DevelopmentMagento2 Basics for Frontend Development
Magento2 Basics for Frontend Development
 
M2ModuleDevelopmenteBook
M2ModuleDevelopmenteBookM2ModuleDevelopmenteBook
M2ModuleDevelopmenteBook
 
Custom PrimeFaces components
Custom PrimeFaces componentsCustom PrimeFaces components
Custom PrimeFaces components
 
Make implementation of third party elements in magento 2 in 5-times easier
Make implementation of third party elements in magento 2 in 5-times easierMake implementation of third party elements in magento 2 in 5-times easier
Make implementation of third party elements in magento 2 in 5-times easier
 
Architecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling ToolArchitecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling Tool
 
Actionview
ActionviewActionview
Actionview
 
Asp.Net 2.0 Presentation
Asp.Net 2.0 PresentationAsp.Net 2.0 Presentation
Asp.Net 2.0 Presentation
 
Silverstripe 2.4-highlights-gpmd
Silverstripe 2.4-highlights-gpmdSilverstripe 2.4-highlights-gpmd
Silverstripe 2.4-highlights-gpmd
 
Html 5, a gentle introduction
Html 5, a gentle introductionHtml 5, a gentle introduction
Html 5, a gentle introduction
 
46h interaction 1.lesson Hello world
46h interaction 1.lesson Hello world46h interaction 1.lesson Hello world
46h interaction 1.lesson Hello world
 
Magento Theme from Development to Importance in 2022.pptx
Magento Theme from Development to Importance in 2022.pptxMagento Theme from Development to Importance in 2022.pptx
Magento Theme from Development to Importance in 2022.pptx
 

Recently uploaded

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
Bhaskar Mitra
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Ramesh Iyer
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 

Recently uploaded (20)

Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Search and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical FuturesSearch and Society: Reimagining Information Access for Radical Futures
Search and Society: Reimagining Information Access for Radical Futures
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 

How To Create Theme in Magento 2 - Part 1

  • 1. The Essential Tutorial: HOW TO CREATE THEME IN MAGENTO 2 A publication of
  • 2. Whoever you are an extension or theme developer, you should spend time reading this blog post because you’ll 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. Part 1
  • 3. Elements a. Theme structure in Magento 2 b. Layout c. New language style – LESS d. Mage_page element The fundamental elements in theme package in Magento 2
  • 4. a. Theme structure in Magento 2 MVC structure in Magento 2 is clearer than in Magento 1.x. Modules in Magento 2 will also be added View element in the module folder structure. Catalog module: app/code/Magento/Catalog/ is an example for you.
  • 5. Please pay attention to View element which is in the same position with Controller, Model. In the View folder, there are below elements:
  • 6. We can see that the inside structure has 3 elements, in which base element is moved out from <area>. The folder structure in <area> folder includes layout, templates, web. For example, frontend has 3 fundamental folders
  • 7. + Layout folder contains all the layout file of module (similar to layout file of Magento 1.x which is contained in all layout folders of theme). The code of these layouts, of course, have different structure. I will write in details in the specific part for layout file below. + Template folder has all template.phtml file, which is file rendered into html as we know in Magento 1.x, inside code is not very different, just php code mixes with html code. + Web folder is a totally new folder in Magento 2. You can see the image in the next slide
  • 8. New Web folder in Magento 2 + The folders: css – stylesheet, js, media – images are grouped. It replaces for 3 folders: css, images, js in previous skin/frontend/base/default. In other words, in Magento 2, the old skin folder is removed and divided into elements in each module.
  • 9. b. Layout In Magento 2, each module has a default layout which can be overwritten and expanded by another layout. Eg: app/code/Magento/Catalog/view/frontend/layout/default.xml Magento 2 separates layout files into particular handle
  • 10. Handle declaration is nearly the same as the previous rule: catalog_product_view – is a handle according to module and controller action The definition for page we want to apply the layout is more specifically by declaring catalog_product_view_type_simple_id_128 Or we can call to include other handles Here is the example about layout file position of Catalog module:
  • 11. Handle declaration is nearly the same as the previous rule: catalog_product_view – is a handle according to module and controller action The definition for page we want to apply the layout is more specifically by declaring catalog_product_view_type_simple_id_128 Or we can call to include other handles Here is the example about layout file position of Catalog module:
  • 12. + Base layout is a default layout area of each module. It’s not recommended to edit in these layout files if it’s 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 Base Layout
  • 13. + 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/ Theme Layout
  • 14. + 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: To create a layout file, follow the rules: <layout xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <update handle="page_one_column" /> <referenceContainer name="content"> <!-- ... --> </referenceContainer> </layout>
  • 15. + 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 order to read and process layout files is described as below:
  • 16. + 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 The steps to proceed layout of the system:
  • 17. Here is the model of processing layout
  • 18. Here is the model of processing layout Tip: Read this blog post to see detailed explanation
  • 19. + Container: The area to distribute page elements Layout/Block Area
  • 20. + Block: the area where default block elements of Magento are in container Layout/Block Area
  • 21. The sample of layout content <container name="container.1" label="Container 1" as="container_1" output="1" htmlTag="div" htmlId="container-1" htmlClass="container"> <block class="MagentoModuleBlockClass" name="block.1"> <container name="child.container" label="Child Container" as="child"> <block type="MagentoModuleBlockClass" name="block.2"> </container> <block class="MagentoModuleBlockClass" name="block.3"/> </container> <container name="container.2" as="container_2" htmlTag="div" htmlId="container-2" htmlClass="container"/>
  • 22. c. New language style - LESS LESS is added as higher-level than CSS. It is translated into CSS thanks to LESS library in php. We’re still allowed to add CSS URL in the source to use directly. Use via LESS: The pre-process LESS language in Magento 2 is through library in lib/internal/Magento/Css/PreProcesso
  • 23. c. New language style - LESS LESS is added as higher-level than CSS. It is translated into CSS thanks to LESS library in php. We’re still allowed to add CSS URL in the source to use directly. Use via LESS: The pre-process LESS language in Magento 2 is through library in lib/internal/Magento/Css/PreProcesso Tip: Want to know more about LESS. Go to this tutorial and find an example
  • 24. The Mage_page element in the previous Magento version is replaced by Mangento_Theme module d. Mage_page element
  • 25. So, we’re done for the 1st part. Have any questions? Tell us blog.magestore.com
  • 26. Download PDF File Visit Magestore Blog to download pdf file of this tutorial & update latest tutorials about Magento 2
  • 27. Download PDF File Visit Magestore Blog to download pdf file of this tutorial & update latest tutorials about Magento 2 Magestore Blog: How to Create theme in Magento 2