Questions tagged [layout]

Denotes the xml files used to define the block hierarchy which eventually renders the template files.

Filter by
Sorted by
Tagged with
93
votes
4answers
45k views

Explanation of UI Component Grid in Magento 2

Is there a good explaination and/or sample of the bare minimum configuration needed to create a UI Component Grid in Magento 2? I know there are myriad core components, such as ./vendor/magento/...
52
votes
6answers
34k views

Magento 2: Changing a Block's Template

In Magento 1, as a module developer it's possible to change a block's template using layout XML code something like this <reference name="block_to_change"> <action method="setTemplate"&...
50
votes
4answers
21k views

Magento 2: how do customer sections / sections.xml work?

I recently came accross a new concept in Magento 2 that I found interesting: customer sections Some of you may have notice the presence of sections.xml files that look like this: <?xml version="1....
36
votes
6answers
41k views

Debugging layout XML loading

TL;DR: is there a way I can debug the loading of the layout? As I believe one module's layout is conflicting with another. Related to a previous question I made: How to make a module layout to be ...
36
votes
3answers
55k views

Remove block from layout in Magento 2

In Magento 1 I could remove a block added by a layout file by adding this in my layout block <remove ="block_id_here" /> How can I do the same for Magento 2? As a practical exercise, let's say ...
35
votes
7answers
35k views

Move all Javascript includes to before </body>

Does anyone know how to have all of Magento's JS script tags e.g. <script type="text/javascript" src="http://sitename.com/js/prototype/prototype.js"></script> render out before the closing ...
32
votes
3answers
30k views

Conditionally show/hide blocks in layout XML

How to conditionally add a block (depending on the configuration in the admin panel) in Magento's layout XML? We can check if config is true on actions. In the example below, if sample/config/...
26
votes
3answers
5k views

When to use 'name' and when to use 'as'

I've found that when trying to use the unsetChild method, sometimes I have to use the 'name' attribute and others 'as'. It seems that if a block is added normally, you use 'as' but if it is added to ...
23
votes
1answer
7k views

Magento2: what is the difference between referenceContainer and referenceBlock

Both referenceBlock and referenceContainer entities are used in layout in magento2. What is the main difference between them and how can I relate these entities to magento1.*.
23
votes
1answer
13k views

Magento 2: Adding Arbitrary HTML to the <head> of Every Page?

In Magento 2, is it possible to add an arbitrary bit of HTML to every frontend/cart page's <head/>? I know I can add a block to the content/<body> area with code something like this <...
22
votes
3answers
4k views

Targeting multiple layout handles in layout XML

I have a custom controller accessed at the path /custommodule/customer/info which is loading the 2columns-left.phtml template on the root node as follows: <custommodule_customer_info> <...
22
votes
2answers
4k views

what does “displayArea” and “provider” of checkout_index_index.xml mean in magento2

what does displayArea and provider of checkout_index_index.xml mean in magento2?
22
votes
4answers
44k views

Best Practices Way to Edit Magento Top-Links

Let's say we want to add a shopping cart icon right before the "My Cart" link on Magento's top links (see top links below). What is the best way to do this? Do something to toplinks.php? Do ...
21
votes
2answers
7k views

Difference between <remove name=”" /> and <action method=”unsetChild”> in layout

What is the difference between <action method=”unsetChild”> and <remove name=""/>? Both functions are used to remove a block from the layout. Could someone explain with an example?
21
votes
1answer
5k views

Block with Cachable=false not rendered on product view page

I am using magento2-1.0.0-beta4 I have copied the checkout.root block from app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml to the product page. Everything is working fine, ...
19
votes
2answers
6k views

Usage of page factory class in magento2

What is the purpose of rendering the custom module page in Magento2 using the result factory \Magento\Framework\View\Result\PageFactory class injected in the constructor and making the page to display ...
18
votes
3answers
21k views

Magento 2 remove “Estimate shipping costs and tax” from cart

I want to get rid of the "Estimate Shipping costs and Tax" block in the cart. The devdocs tell Disabling a component is the way to go, so I tried the following: <body> <referenceBlock ...
18
votes
6answers
23k views

Remove “product information, reviews, tags” block from product page

I am trying to remove a certain block from my product page in Magento, but can't seem to find where I should delete it. I think it's somewhere in the XML files, but since I'm not that good of a web-...
18
votes
3answers
2k views

Difference Between “page” and “layout” Root Tags in Magento 2

In Magento 2, some layout handle XML files open with the <page.../> root tag. Others open with the <layout.../> root tag. Does using either of the above tags introduce any ...
18
votes
2answers
9k views

Google CDN jQuery with Local Fallback in Magento Layout XML

I've done the following to include jQuery from Google CDN in Magento: <default> <reference name="head"> <block type="core/text" name="google.cdn.jquery"> <...
17
votes
6answers
24k views

How to add/remove links on my account navigation magento2?

How to remove "Billing Agreements" and "My Wishlist" links from the navigation menu on customer account page?
17
votes
3answers
49k views

How to change the layout of the all products page?

Can anyone tell me where I can change the layout of the all products page? I think this page is now having 3columns.phtml layout but I need 2columns-left.phtml layout.
16
votes
4answers
31k views

Magento 2 : Adding static blocks to specific section of pages with custom module layout xml file

In magento 1.x it is possible to add a static block using xml layout file. <reference name="root"> <block type="cms/block" name="name"> <action method="setBlockId"&...
16
votes
7answers
18k views

Add header and footer in checkout page Magento2

By default Magento 2 don't provide HEADER and FOOTER in CHECK OUT page. So I checked checkout_index_index.xml file on path app/design/frontend/package_name/theme_name/Magento_Checkout/layout/...
16
votes
1answer
9k views

Magento 2 - ifconfig in layout xml

I'm working with magento 2. I can use ifconfig attribute in the block code, and it works well. <block class="Magento\Catalog\Block\Category\View" name="category_desc_main_column" template="...
16
votes
1answer
2k views

How can I include the checkout progress on the Paypal express review page?

Okay I've broken this down into steps and you can see where I am stuck: Step 1 - change column number The PayPal express review page (our page that PayPal sends the buyer back to in order to review ...
15
votes
2answers
12k views

Remove a UI component child via Layout XML

How do I remove a UI component child via Layout XML? For example, from the below xml directive in checkout_index_index.xml. How do I remove the shipping node ? <item name="sidebar" xsi:type="array"...
15
votes
3answers
403 views

The block from my custom module isn't showing up on the product page. How can I debug?

I am making my first custom module, following a tutorial online. I get that I have to create certain XML files for the system to "discover" my module, but even when I break the XML, I don't see any ...
15
votes
2answers
10k views

What is the correct way/approach to modify a Magento template?

Please suggest me the right approach, I want to customize the "EMAIL to Friend" page into pop up window, when user click on the button (email this product). By enabling template hinting, I found out ...
15
votes
5answers
12k views

Magento 2: How to set custom template for core block

I'm trying to override the register.phtml in my module, but it seems there are some config problem that make Magento unable to use my custom template to override the one in core module. I've checked ...
15
votes
1answer
3k views

Incorrect loading order of Layout XML

When I create a layout file for the admin area (whether in the community or local code pool), sometimes Magento is loading that layout xml in before the Adminhtml module layout xml is loaded. The ...
15
votes
3answers
20k views

Magento adding CSS and JS includes to the footer

I'm doing some Yslow optimization of my Magento site and am trying to add the CSS and Js to the footer of the site. At the moment I'm using a head reference tag in the layout XML and using addJs and ...
14
votes
14answers
15k views

Magento2 : Change order of Tabs on Product Page

I'm trying to change the order of the tabs on the product page in Magento 2. Default is Details|More Information|Reviews. I tried: Vendor/theme/Magento_Catalog/layout/catalog_product_view.xml <...
14
votes
2answers
32k views

Adding custom layouts for CMS and Category use with custom module trouble

I have a category in my store that requires a totally different layout to the standard Magento layouts. So I created a new copy of the 1column.phtml and renamed it and made one small change to test. ...
14
votes
1answer
7k views

How can I debug layout file processing in Magento 2?

According to magento 2 theme specification about Layout files processing : The Magento application processes layout files in the following order: 1/ Collects all layout files from modules. The ...
14
votes
3answers
1k views

Is there a local theme layout XML file other than local.xml?

I've built a theme by creating and editing the following file: frontend/mypackage/default/layout/local.xml I have a store view "site1", and wish to make exceptions on the default local.xml of "...
14
votes
2answers
300 views

Which one step checkout type extensions honour original layout handle? [closed]

One of my extensions uses the below layout xml instruction to add a common block for three payment methods to the checkout <checkout_onepage_paymentmethod> <reference name="root"> ...
13
votes
6answers
14k views

How to remove Company field from checkout process in Magento 2?

How to remove Company field from checkout process in Magento 2? I've been looking for the template but have not found it. Update: Is there any way to remove this field via layout or template?
13
votes
2answers
11k views

CMS XML Handles for Layout Updates

I've had a few scenarios where I've tried to use the cms handles to update a cms page's layout. For example I was trying to use the cms_index_index handle referencing root and setting the page ...
13
votes
5answers
528 views

How to make a module layout to be shown on all themes

Here is the situation: I have several self made modules, all tested and working using the default theme. Then we bought and installed a new theme. Switched to the new theme and the modules are not ...
13
votes
4answers
9k views

Magento 2: Remove block depending on a config setting

I'm trying to remove a block from a certain page (be it frontend or backend) but only if a certain config flag is set to true. Let's take an example. I want to remove the block with the name dashboard ...
13
votes
4answers
6k views

What is the proper way of positioning/ordering CSS files in Magento 2?

In the Magento 2 DevDoc it says To include a CSS file, add the <css src="<path>/<file>" media="print|<option>"/> block in <head> section in a layout file. However it ...
13
votes
3answers
9k views

Remove toolbar from product list via local.xml

I am used to using local.xml for my layout updates, however I cant seem to remove the toolbar from the product list block using either the remove or unsetChild methods. Can anyone say if this is ...
13
votes
2answers
11k views

Template path not showing

For some reason the template path hints are not displayed. I went to the admin panel and turned them off and on again, then cleared the cache. But they are still not displaying. How can I debug/...
13
votes
2answers
2k views

Checkout Form - How to wrap multiple elements in a class - Magento 2

How do you wrap two checkout form elements inside a div? For example let's say I wanted to wrap these country and zip/postcode fields in a div with the class of example-class, how would I do this? ...
13
votes
3answers
8k views

Possible to change block type in layout XML?

Is it possible to change a block type in layout XML? I know how to change template using setTemplate method, but I am trying to change a block's type. Is this possible?
13
votes
4answers
3k views

Cancel removal process of block in layout.xml

I want to undo the removal of a block. the block is removed in vendor/magento/theme-frontend-blank/Magento_Checkout/layout/checkout_index_index.xml <referenceBlock name="minicart" remove="true"/&...
12
votes
4answers
23k views

Add new tab on product detail page Magento 2 [duplicate]

I want to add an extra tab on product detail page just like review tab, It will look like a product question tab. How can I do this? My block file: namespace Example\ProductQuestion\Block; use ...
12
votes
1answer
5k views

Magento 2 custom theme layout xml and css not working

I created a new theme and it was working fine but after a few days, I realized some things weren't working. default_head_blocks.xml is no longer pulling in any css files that I include (both hosted ...
12
votes
6answers
17k views

How to remove page title (h1) from home page, cms_index_index.xml not working

I´m trying to remove the home page main title on my custom theme (wich is running on top of luma theme). I´ve tried to add the usual tag to remove, as follows (and as it was already answered here), ...