Lesson3: Layout files and handles in magento2

0
57
layout handles magento2

This article describes the basic concepts you need to know about layout file, and handles in magento2

I. Layout files.

For a particular page, its layout is defined by two major layout components: page layout file and page configuration file.

A page layout file defines the page wireframe, for example, one-column layout. Technically page layout is an .xml file defining the structure inside the <body> section of the HTML page markup. Page layouts feature only containers. All page layouts used for page rendering should be declared in the page layout declaration file.

Page configuration is also an .xml file. It defines the detailed structure (page header, footer, etc.), contents and page meta information, including the page layout used. Page configuration features both main elements, blocks and containers.

1. What components can layout files be found in?

● Modules
● Themes

2.What is the file structure of layout files?

● Modules
○ view/<area>/layout/<layout_handle>.xml
● Themes
○ <Vendor_Module>/layout/<layout_handle>.xml

II. Layout handles.

1. What is a layout handle?

● A string that associates a layout XML file with a specific page or group of layout instructions
● e.g. the customer_account_login handle relates to the file of the same name: customer_account_login.xml

2. How are handles linked to routing?

● Whilst handles can be programmatically added to a page
● Most are generated based on the current page route / url

● http://www.myawesomestore.com/customer/account/login
● customer_account_login.xml

3. What are common layout handles?

common layout handles in magento2

common layout handles in magento2

4. How many handles can be on one page?

● Multiple, no limit
● At a minimum: default and the current route handle