26

Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Embed Size (px)

Citation preview

Page 1: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features
Page 2: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

● Built on HTML5 and CSS3 technologies● jQuery out of the box (w jQuery UI)

● Preprocessing language● LESS based Magento UI Library

● Out of the box Compiling engines

Hello, Magento 2!

Page 3: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

StructureModule files

app/code/Magento/<module_name>/view/frontend/

Theme files

app/design/frontend/<vendor>/<theme_dir>/Magento_<Module_name>/layout

”Layouts” / “Templates” / “Web”

Page 4: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features
Page 5: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features
Page 6: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features
Page 7: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Static filesPub/static

Excluded from fallback mechanism

Files served from cache only

After new module has been installed, you need to clear “pub/static” folder

lib/webPart of the Magento Framework

Contains LESS UI library and Javascript files

Page 8: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Magento ModesDefault

NOT optimized for production, static view files are cached

DeveloperStatic view files are not cached; they are written to the pub/static directory every

time they’re called

ProductionStatic files are cached and served from cache only

Page 9: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Theme● Responsive Default theme

● No more “skin” folder● Infinite fallback mechanism

● Few files required for theme to work● Visual design editor

Page 10: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Create your theme

/app/design/frontend/<vendor>/<Theme_name>

Page 11: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Declare your theme/app/design/frontend/<vendor>/<Theme_name>/theme.xml

Page 12: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Register your theme/app/design/frontend/<vendor>/<Theme_name>/registration.php

Page 13: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Configure images

/app/design/frontend/<vendor>/<Theme_name>/view.xml

Create directories for static files(just like you did in “skin” folder in M1)

/app/design/frontend/<vendor>/<Theme_name>/web/

Page 14: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features
Page 15: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Working with templates●Root.phtml as root template for all pages in

applicationapp/code/Magento/Theme/view/base/templates/root.phtml

●E-mail templates inside Sales moduleapp/code/Magento/Sales/view/frontend/email

Page 16: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Overridingcode/Magento/Checkout/view/frontend/templates/cart.phtml

to

desing/frontend/<vendor>/<theme>/Magento_Checkout/templates/cart.phtml

Page 17: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Layouts●What was once called “handle”, is now separated

layout file●<container> , <referenceContainer>,

<referenceBlock>

Page 18: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

<container name="container_name">...</container>

<referenceBlock name="block_name">...</referenceBlock>

<referenceContainer name="name">...</referenceContainer>

Page 19: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features
Page 20: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Extending vs overriding layoutscode/Magento/Checkout/view/frontend/layout/file.xml

to

<theme>/Magento_Checkout/layout/file.xml

vs

code/Magento/Checkout/view/frontend/layout/file.xml

to

<theme>/Magento_Checkout/layout/overide/<theme>/file.xml

Page 21: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

CSS● LESS Preprocessor

● LESS UI Library● 2 compilation modes

Page 22: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Server-side Compilation● Default compilation mode

● ONLY option in production mode● Compilation is performed on the server, using LESS PHP Library

Page 23: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Client-side Compilation● Available in Default and developer modes

● Files are compiled in browser, using LESS.js

Page 24: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

//@Magento_import● Magento-specific LESS directive

● files with the same name, from different locations can be included

● Must be commented out with two slashes //

Page 25: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Questions?

Page 26: Nenad Andrakovic - Changing the way frontend developers think and work - Magento 2 frontend features

Thank you! :)