2

Because the customer_account.xml layout file doesn't match any front actions, then how this handle called and what are the places this is used, is it possible to have custom handles and add into the layout?

5 Answers 5

3

That file will be used for all front actions like customer/account/*

So if you include any CSS or JS in it, it will be included in all customer/account/* pages.

1
  • or any common sidebar, sidebar links or anything which should be common to customer/account controller folders. Commented Jun 19, 2018 at 4:26
3

customer_account.xml is used for customer account page in frontend.

You can handle any number of customer account pages using this handle.

<update handle="customer_account"/>

customer_account.xml file is having customer_account handle and this handle then will be added to any customer account related pages. So, if you add small code to any frontend new module layout xml file and add customer_account handle then customer account left navigation and all things will be updated accordingly.

below is the code to add customer_account handle to any customer account layout file.

customer_account_index.xml

<customer_account_index translate="label">
    <update handle="customer_account"/>
</customer_account_index>
2

this is common for all routes starting with customer/account/*. you can also create your own layout file which should be common to all controller folder. i-e for url anc.com/catalog/product/view where catalog is the frontname and product is the controller folder and view is the controller class, if you want to make any common file which should be applicable to all catalog/product/* routes then you can create catalog_product.xml and same is the case of customer_account.xml or any of your custom controller routes.

2

Yes it is correct customer_account.xml layout file doesn't match with any front actions. Its created to separate the common code for customer account section. if you check the code currenlty its adding common css class and sidebar navigation for all the customer account pages.

How it is called for all the customer account pages?

Its called using update tag in layout file. If you check customer_account_edit.xml, customer_address_index.xml files, you will found the below code to include customer_account.xml file in particular handle.

<update handle="customer_account"/>
1

customer_account.xml file defines the basic layout structure of customer account sections. The customer account pages (eg: order listing, address listing, new address creation etc) has lot of blocks in common and hence it is very wise to define such repeating layout blocks in a single file and later reuse it in separate customer account pages.

How this handle is called?

If you check the landing page of customer account section i.e, dashboard page, the layout handle responsible is customer_account_index and there you can find below definition:

<customer_account_index translate="label">
    <update handle="customer_account"/>
</customer_account_index>

So there is a special node <update /> to include a custom layout handle inside another layout handle through the layout files. You can also add a handle programmatically. This is how <default /> handle is added by Magento, but which is a separate topic.

You can use this same concept, if you have similar kind of needs.

what are the places this is used

This is used in every customer account section pages to keep the customer account section intact same except for the "real" content section.

Is it possible to have custom handles and add into the layout

As I stated above, yes you can and you should in order to avoid duplication of layouts.

Custom layout handles and their brave usages are some time helps us to avoid big chaos, especially when someone loves to use the layout way of update instead of programmatically change something in the layout.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.