Magento 2 features include:
- Relocating and localizing skin files to allow for multiple locales per skin
- Modular view files that are independent of themes and can be overridden by modules
- Containers to define the structure of page elements like blocks and other containers
- Page types to define specific layout handles for controllers to use uniquely
- These changes improve modularity, localization, and developer control over the view layer.
5. • Skin – look and feel of a theme, colors & styles
• Skin files – static, web-accessible
Magento Skin
6. • Skins are located separately from themes
• Any skin can be chosen for any theme
• Incompatible skin can be chosen for a theme
“example” package
“default” theme
“mobile” theme
“default” skin
“modern” skin
“simple” skin
Magento 1.x Skin
7. • Skin belongs to one theme only
• Skin is located within a theme
• Skin files web-access challenge
“example” package
“default” theme
“mobile” theme
“default” skin
“modern” skin
“simple” skin
Magento 2 Skin
8. • New skin for every locale
• Inconsistent configuration: locale + localized skin
“example” package
“default” theme
“default” skin
“german” skin
“french” skin
Magento 1.x Skin Localization
14. • Referring modular file
<Namespace>_<Module>::file.ext
• Omit module scope
• If template used solely within its own module
• In module’s configuration file*
• In module’s layout update file*
• In module’s CSS file*
* - not implemented yet
Module Scope
17. • Single interface for skin and JS lib files
• Simplified HTML <head> tag manipulation
• Skin can override JS lib files
• Skin may require specific version of JS lib
JavaScript Libraries Fallback
21. Container vs Block
• Block – unit of a page output
• Container – unit of a page structure
• Container consists of
• Blocks
• Containers
• Container renders all children
22. Containers in Layout Updates
<container> directive attributes:
• name – unique name
• label – human-readable label
• html{Tag,Id,Class} – HTML tag name & attributes
<?xml version="1.0"?>
<layout version="2.0">
<example_handle>
<container name="root_container" label="Root Container" htmlTag="div">
<block type="Mage_Core_Block_Template" name="block1" template="1.phtml"/>
<container name="nested_container" label="Nested Container"/>
</container>
24. Magento 1.x Page Rendering
• Layout handle – instructions of visual elements positioning
and properties
• Controller uses arbitrary layout handles
25. Page Types
• Page types – special layout handles
• Controller uses one page type only
• Page type may inherit a page type
• Inherited page types are loaded implicitly
29. Thank You!
Q & A
Sergey Shymko
sergey.shymko@magento.com
Editor's Notes
Design package (instance) – group of themes/skins
Multiple skins may exists for a theme
Same skin can be used for multiple themes.
However, It’s practically impossible to create skin compatible with multiple themes.
Text in images, JavaScript, etc.
Better skin files reuse
Workaround for absence of true view modularity
View files are divided by areas
Theme & skin files reside together
Theme/skin files distinguished by extension
Theme/skin can refer to module’s files
Module cannot refer to theme/skin
Skin file lookup is performed within the <current> package only
There can be different ways to provide web access. We’ve chosen the publication.
Algorithms
With files duplication – faster, more storage space
Without files duplication – slower, less storage space
Blocks don’t guarantee children rendering, it’s up to template.
Converted to containers
Mage_Core_Block_Text_List
Mage_Page_Block_Html_Wrapper
Used layout handle not always corresponds to action name
Any combination of layout handles can be used
No way to determine actual number of pages a website has
Page type breadcrumbs & navigation
Drag-n-drop of blocks & containers