Skip to main content
24 votes

How to render HTML with AJAX in Magento 2

I would also go the way 2 and, indeed, you actually can render "pure" HTML via AJAX without the head, body, css and so on. The trick is to: tell your controller to instanciate a Response that is of ...
Hervé Guétin's user avatar
22 votes
Accepted

How to remove reference container block from layout?

You can remove using that code: <referenceContainer name="footer-container" remove="true"/> <referenceBlock name="form.subscribe" remove="true"/>
Rafael Corrêa Gomes's user avatar
17 votes
Accepted

Add .phtml file on all pages magento 2

Add this code in your custom theme or module in default.xml: app/design/frontend/Namespace/Themename/Magento_Theme/layout/default.xml <referenceContainer name="after.body.start"> <block ...
D Singh's user avatar
  • 1,144
13 votes

Is it possible to remove elements in a page layout in Magento2?

What about: creating a new container (instead of a block) move your blocks to the container remove the container Something like this: <container name="delete" htmlTag="div" htmlClass="delete"/&...
Raphael at Digital Pianism's user avatar
11 votes
Accepted

What is the use of page_types.xml at magento2

The page_types.xml file allows an admin to add custom content to all the controller actions defined in it. If you want to allow the admin to add custom block to your new page you can add it to the ...
bluscience's user avatar
7 votes

Is it possible to remove elements in a page layout in Magento2?

This is the best practice for remove any block or container in magento 2. You can pass name attribute inside name in below element. <referenceBlock name="block.name" remove="true" /> You can ...
Rakesh Jesadiya's user avatar
7 votes

Magento 2 add new custom container above <main> tag

<referenceContainer name="page.wrapper"> <container name="{your_name}" htmlTag="div" before="main.content"> <!-- must have content to display --> <block name="{...
steros's user avatar
  • 1,622
7 votes

Add .phtml file on all pages magento 2

Try below steps Step:1 Create default.xmlat location app\code\<Vendor-Name>\<Module-Name>\view\frontend\layout and add below code <referenceContainer name="page.top"> <block ...
Abdul's user avatar
  • 9,701
6 votes

Remove Css and js from new custom page_layout from header and body Magento 2

Adding new CSS <theme-dir>/blank/layout/default_head_blocks.xml <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:...
karthick's user avatar
  • 675
5 votes

Title tag in layout is not translated

It still does not seem possible to set a title in the head section and translate it, but you could create a custom customer_account_forgotpassword.xml to fix the issue with this code <...
LucScu's user avatar
  • 2,332
5 votes

How to render HTML with AJAX in Magento 2

Out of the box, Magento does not use any of those methods to render HTML via AJAX. From what I've seen, everytime such thing needs to be done, JSON is used to transport the result. Example from the ...
Raphael at Digital Pianism's user avatar
5 votes
Accepted

Magento2.1.5: Login and registration form on login page

You can customize login layout here vendor/magento/module-customer/view/frontend/layout/customer_account_login.xml Account create layout vendor/magento/module-customer/view/frontend/layout/...
Prince Patel's user avatar
  • 22.8k
5 votes
Accepted

Magento 2 Add css class to <a> tag in customer account navigation

Try following way: <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link-2"> <arguments> <argument name="path" xsi:...
Sohel Rana's user avatar
  • 35.9k
5 votes
Accepted

Failing to remove page title

put that code in downloadable_customer_products.xml and it will work, please find attached screenshot i have tested in my local.
bhargav shastri's user avatar
5 votes
Accepted

Page Title Move for All Pages - Magento2

If you want to add page.main.title block inside column main then use below line <move element="page.main.title" destination="main" before="-" /> Or if you want to move that inside columns then ...
Kishan Savaliya's user avatar
4 votes

Where can I see a different between cacheable="true" and "false" in layout?

Let's start at the Magento\Framework\View\Layout::getOutput. As you may suspect, this transforms the layout to output. In this method there is a call to renderElement from the same class. This one ...
Marius's user avatar
  • 198k
4 votes

Magento 2 add new custom container above <main> tag

Preferred way is to edit in theme's default.xml file. You may create or edit the default.xml file at path app/design/frontend/Vendor/theme/Magento_Theme/layout/default.xml If one wants to add ...
Kazim Noorani's user avatar
4 votes
Accepted

Magento 2 : Alternate Logo for Page Layout

Create helper to change logo dynamically Override default.xml in your theme and add helper in logo_file argument Magento_Theme/layout/default.xml <argument name="logo_file" xsi:type="helper" ...
Prince Patel's user avatar
  • 22.8k
4 votes

MAGENTO 2 How to Get Current page layout

I wanted to achieve the exact same thing. I ended up creating a helper class that injects both \Magento\Framework\View\Result\Page and \Magento\Framework\View\Layout. The Page object can retrieve the ...
Vernon Grant's user avatar
4 votes

How to add layered navigation in Magento 2 on Top After Menu

There are two ways to achieve this If you want it to be applied into a single category page only then perform following things Go to your Admin_Panel > Catalog > Category > ...
Abhishek Tripathi's user avatar
4 votes
Accepted

Magento 2 : How to add Conditional Links in Layout?

For the top.links and customer_account_navigation you can create your Block class Instead of Magento\Framework\View\Element\Html\Link\Current and add your condition there, like <?xml version="1.0"?...
Keyur Shah's user avatar
  • 18.1k
4 votes
Accepted

Magento 2: Product Detail Layout change

As per your requirement i suggest set your product page layout as 1 column, set your HTML code in left (it contains Images section) & right (product details information) container. For sticky ...
Rik Patel's user avatar
  • 484
3 votes
Accepted

How to render HTML with AJAX in Magento 2

In my example I can not use sections because it is not customer data and it is not after a PUT / POST action but using Raphael at Digital Pianism answer I figured out how Magento render sections. ...
Matthéo Geoffray's user avatar
3 votes

How to remove html head body tags in layout magento 2

I found a better way to get content for ajax calls using any layout and getting exactly the html markup block you need. I wanted to load products depending on the category chosen without a page load ...
hiperboreo's user avatar
3 votes

Magento 2 : Alternate Logo for Page Layout

The better way to do this will be using helper function. in your Magento_Theme/layout/default.xml you can pass argument for logo like this- <argument name="logo_file" xsi:type="helper" helper="...
Piyush's user avatar
  • 5,904
3 votes

Magento 2 : Alternate Logo for Page Layout

I tried, this is working for me very well. Magento_Cms/layout/cms_index_index.xml: <?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:...
Evgeny Levinsky's user avatar
3 votes
Accepted

How do I override layouts.xml - Magento 2

Instead of overriding layouts.xml I ended up doing the following Create a new Module: app/code/<Vendor>/Cms Create the file: app/code/<Vendor>/Cms/Model/PageLayout.php <?php ...
Shawn Northrop's user avatar
3 votes

Add .phtml file on all pages magento 2

Add Custom Template file using xml block into app/design/frontend/<VendorName>/<ThemeName>/Magneto_Theme/layout/default.xml Using referenceBlock tag you can add your custom block into ...
Ronak Chauhan's user avatar
3 votes
Accepted

Magento2 - How to get a custom attribute for catalog product?

To show attribute on product detail page you have to create a template file color_attribute.phtml in Magento_Catalog/templates/product/view folder. and add below code in that template file : <?...
Naveed Asim's user avatar
  • 3,657
3 votes
Accepted

Magento2 Move static block to above footer and below main content

Can you please try this ? <referenceContainer name="page.wrapper"> <block class="Magento\Cms\Block\Block" name="muah_landingpg_footer_banner" before="page.bottom"> <...
Kishan Savaliya's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible