04.07.2019 Views

frontend-developer-1

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Layout XML in Themes<br />

For the example below, we will look at the following URL: https://yoursite.test/<br />

customer/account. When browsing here, the tag contains the following<br />

classes: account customer-account-index page-layout-2columns-left.<br />

The first thing to notice is the use of the module/controller/action syntax. If<br />

one of these parameters are not specified index is used instead.<br />

The customer_account_index layout handle is built from the following elements:<br />

• customer: the route ID, see here. Please note that the route ID can be<br />

different than the front name. When browsing to a page, the front name is<br />

used to match the URL with the controller. When building layout handles, the<br />

route’s ID is used.<br />

• account: the folder as part of the controller.<br />

• index: the controller’s action, as it was not specified in the URL above: see<br />

this link.<br />

So how does this map to a layout XML file? Layout XML files are stored in a<br />

module’s view/[area]/layout directory.<br />

We can then take the layout handle and look for a file in the layout directory with<br />

that name. If you are using PHPStorm, a fast way to do this is by tapping the `Shift`<br />

key twice and entering the filename you wish to locate.<br />

Any of the layout handles listed above can affect the output of a page. The<br />

customer_account_index.xml file will be specific to the customer dashboard.<br />

Copyright © 2018, SwiftOtter, Inc.<br />

31

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!