Questions tagged [layout]
Denotes the xml files used to define the block hierarchy which eventually renders the template files.
2,789
questions
103
votes
4
answers
54k
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/...
65
votes
4
answers
42k
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....
61
votes
6
answers
60k
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"&...
45
votes
3
answers
89k
views
Remove block from layout XML 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 ...
37
votes
6
answers
42k
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
7
answers
37k
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 ...
34
votes
3
answers
34k
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/...
29
votes
5
answers
37k
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 ...
26
votes
3
answers
7k
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?
26
votes
3
answers
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 ...
25
votes
6
answers
36k
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?
25
votes
1
answer
14k
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
<...
23
votes
15
answers
28k
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
<...
23
votes
1
answer
9k
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
4
answers
45k
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 ...
22
votes
3
answers
5k
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>
<...
21
votes
10
answers
29k
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/...
21
votes
2
answers
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
1
answer
7k
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, ...
20
votes
2
answers
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
...
20
votes
2
answers
18k
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="...
19
votes
3
answers
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
2
answers
18k
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"...
18
votes
6
answers
24k
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
2
answers
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">
<...
18
votes
1
answer
11k
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 ...
17
votes
3
answers
50k
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
5
answers
9k
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 ...
16
votes
5
answers
13k
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 ...
16
votes
1
answer
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
7
answers
28k
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), ...
15
votes
4
answers
34k
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"&...
15
votes
4
answers
14k
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 ...
15
votes
3
answers
19k
views
Magento 2: style-m.css vs style-l.css
How style-m.css and style-l.css files are generated in Magento2?
In theory style-m.css should have less code and to have styles only for mobile devices than style-l.css in order to load on mobile ...
15
votes
2
answers
11k
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
3
answers
440
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
1
answer
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
3
answers
21k
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
6
answers
31k
views
Find out the "name" for a referenceBlock in Magento 2
I want to remove some blocks from my page. Say for example that I want to remove the container for the logo.
Then I create /app/design/frontend/MYVENDORNAME/MYTHEMENAME/Magento_Theme/layout/default....
14
votes
2
answers
57k
views
Move blocks to other container how to
Being newby I look for a workaround to move Sign in and Store switcher from header.panel to header.container. I just tried this code but won't work
<referenceContainer name="header.container">
...
14
votes
4
answers
37k
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 ...
14
votes
2
answers
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
4
answers
28k
views
Pass data to getChildHtml() or call method on child block
I want to be able to pass data to the getChildHtml() call. The reason is, the output of the block is dependant upon a product type. So i want to pass the product to the getChildHtml so that it can ...
14
votes
2
answers
10k
views
Magento 2 : How to add placeholder text to street fields in checkout?
In back-end I've set the street address to have 3 lines.
I'd like to put a different placeholder in each field:
Street
Building / Apartment
Area
This way user can enter data in a more structured ...
14
votes
2
answers
4k
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?
...
14
votes
3
answers
2k
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
2
answers
324
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
2
answers
8k
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 ...
13
votes
7
answers
21k
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
2
answers
15k
views
Magento2: Default to sort by price descending not ascending
Ok so I have my categories sorting by price. Magento 2 defaults this to price ascending. But I would prefer it to be by price descending.
Pretty sure I can do this by customising ...