SlideShare une entreprise Scribd logo
1  sur  27
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

Contenu connexe

Tendances

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 kcSuman 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 MagentoEric 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 2Mathew Beane
 
Finding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeFinding Your Way: Understanding Magento Code
Finding Your Way: Understanding Magento CodeBen Marks
 
MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2MidwestPHP - Getting Started with Magento 2
MidwestPHP - Getting Started with Magento 2Mathew 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 VersionMeet 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 2015Joshua 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 ThemeM-Connect Media
 
Meet Magento Belarus - Sergey Ivashchenko
Meet Magento Belarus - Sergey IvashchenkoMeet Magento Belarus - Sergey Ivashchenko
Meet Magento Belarus - Sergey IvashchenkoAmasty
 
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 DistributionMeet Magento Italy
 
Magento 2 Development
Magento 2 DevelopmentMagento 2 Development
Magento 2 DevelopmentDuke Dao
 
Max Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMax Yekaterynenko: Magento 2 overview
Max Yekaterynenko: Magento 2 overviewMeet 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 performanceMeet 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 2Meet Magento Italy
 
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
 

Tendances (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
 

En vedette

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 2015Joshua Warren
 
Magento 2 Admin Mobile App
Magento 2 Admin Mobile AppMagento 2 Admin Mobile App
Magento 2 Admin Mobile AppAppJetty
 
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 2Meet Magento Italy
 
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 LeonovaElena 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
 

En vedette (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.
 

Similaire à 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.0MageWorld
 
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.0Daniele 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 extensionBun 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 developmentKapil 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
 
Magento2 Basics for Frontend Development
Magento2 Basics for Frontend DevelopmentMagento2 Basics for Frontend Development
Magento2 Basics for Frontend DevelopmentKapil 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 easierElena Kulbich
 
Architecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling ToolArchitecture Specification - Visual Modeling Tool
Architecture Specification - Visual Modeling ToolAdriaan Venter
 
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 introductionDiego Scataglini
 
46h interaction 1.lesson Hello world
46h interaction 1.lesson Hello world46h interaction 1.lesson Hello world
46h interaction 1.lesson Hello worldhemi46h
 
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.pptxAgento Support
 

Similaire à 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
 

Dernier

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Dernier (20)

"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

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