Lesson5: Layout directives in magento 2

0
80
layout directives in magento2

I. Layout directives.

1. What are the main layout directives?

● <container/>
● <block/>
● <referenceContainer/>
● <referenceBlock/>
● <move/>

2. What are they for?

layout directives magento2

II. <Container/>

1. What attributes can containers have?

● name
● htmlTag
● htmlClass
● before/after
● and more…

<some_handle>.xml

container magento 2

III. <block/>.

1. What attributes can blocks have?

● name
● class
● template
● before/after
● cacheable (disables FPC for entire page if set to true!)
● and more…

<some_handle>.xml

block xml

IV. <referenceContainer/>.

1. What attributes can reference containers have?

● name
● remove
● display

<some_handle>.xml

referenceContainer magento

referenceContainer magento

referenceContainer magento

V. <referenceBlock/>.

1. What attributes can reference blocks have?

● name
● template
● remove
● display

<some_handle>.xml

referenceBlock magento2

referenceBlock  magento2

referenceBlock magento2

VI. before and after.

1. What are “before” and “after” for?

● To allow elements (blocks / containers) to be placed before or after others

<some_handle>.xml

before and after in  layout xml

2. How can elements be placed first / last within a parent element?

● Using before=”-” / after=”-”

Use after in xml magento 2

VII. <move/>.

1. What attributes can move elements have?

● element
● destination
● before/after

<some_handle>.xml

use move in xml magento2