22

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 type \Magento\Framework\View\Result\Layout rather than \Magento\Framework\View\Result\Page use a layout XML file with a root node that is <layout...>...&...


19

You can remove using that code: <referenceContainer name="footer-container" remove="true"/> <referenceBlock name="form.subscribe" remove="true"/>


18

To meet your requirements you need to create an extension - without this it's not possible. Module config file : Create the module file config file at app/etc/modules/Amit_NewLayout.xml Code: <?xml version="1.0"?> <config> <modules> <Amit_NewLayout> <active>true</active> <...


14

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 class="Magento\Framework\View\Element\Template" name="custom.file" before="-" template="Magento_Theme::html/custom.phtml" ...


13

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"/> <move element="category.image" destination="delete"></move> <move element="category.description" destination="delete"></move> <...


10

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 page_types.xml file. From what I can understand the page_types are referenced in the widget area, under the Layout Updates fieldset of the Storefront Properties ...


7

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 search inside magento 2 system, you have find many places syntax same as above. Its magento recommendation way.If attribute remove="true" then add the element ...


7

<referenceContainer name="page.wrapper"> <container name="{your_name}" htmlTag="div" before="main.content"> <!-- must have content to display --> <block name="{some_content_block}" /> </container> </referenceContainer> Be aware that the container will only display if it has content! Reference: app/...


7

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 class="Magento\Framework\View\Element\Template" name="custom-block-name" template="<Vendor-Name>_<Module-Name>::page\custom.phtml"/> </...


6

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:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <css src="css/newtheme.css" /> </head> </page> ...


5

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 <referenceBlock name="page.main.title"> <arguments> <argument name="title" xsi:type="string" translate="true">Forgot Your Password</argument>...


5

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 Magento/Checkout/Controller/Cart/Add : $this->getResponse()->representJson( $this->_objectManager->get('Magento\Framework\Json\Helper\Data')-&...


5

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/customer_account_create.xml Do not edit directly core file. Copy customer_account_login.xml to your theme. Final customer_account_login.xml: <?xml version="1....


5

Try following way: <block class="Magento\Customer\Block\Account\SortLinkInterface" name="customer-account-navigation-orders-link-2"> <arguments> <argument name="path" xsi:type="string">sales/order/history</argument> <argument name="label" xsi:type="string" translate="true">My Orders 2</argument> ...


5

put that code in downloadable_customer_products.xml and it will work, please find attached screenshot i have tested in my local.


4

You can use the Magento notification system. It should work anywhere anytime. Notice Mage::getSingleton(‘core/session’)->addNotice(‘Notice message’); Success Mage::getSingleton(‘core/session’)->addSuccess(‘Success message’); Error Mage::getSingleton(‘core/session’)->addError(‘Error message’); Mage::getSingleton(‘adminhtml/session’)->...


4

Maybe something like this : <reference name="root"> <action method="unsetChild" ifconfig="general/layout/enable"> <child>header</child> </action> <action method="unsetChild" ifconfig="general/layout/enable"> <child>footer</child> </action> </reference> I'm not sure if ...


4

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 container div under column div, should try this. <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:...


4

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 > Desired_Category > Design Put there below things at appropriate places Layout > 1 Column Layout Update XML > <move element="sidebar.main" destination="...


4

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"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"...


3

currently it still does not seem possible to set a title in the head section and translate it. There is still an open issue for this bug: https://github.com/magento/magento2/issues/2951 you can actually execute the method setTitle via Layout or in code to set a translated title (like mentioned in the issue): in Layout: <referenceBlock name="page.main....


3

You can't do this with a simple layout update xml. The easiest way to achieve this is create a new root template specific to your cms page. Steps for this is given below. 1. Layout Update XML File Go to CMS > Pages > [Select your CMS Page] > Design > Layout Update XML section. Put this layout update code there. <!-- removing default page ...


3

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. If we take the example of cart section it use the method \Magento\Customer\CustomerData\SectionPool::getSectionDataByNames to retrieve data from sections. This ...


3

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 renders each element of the page. In this method, the event core_layout_render_element is dispatched. And this event is observed by the PageCache module. <...


3

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="Namespace\ModuleName\Helper\Data::getLogoImage"></argument> and then in your helper file you can return logo based on current url, Your helper file- ...


3

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" helper="Vendor\Module\Helper\Data::getLogo"></argument> In your helper, you can get logo based on current url like this. <?php namespace Vendor\...


3

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:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <body> <referenceBlock name="logo"> <...


3

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 selected layout using the method named getConfig()->getPageLayout(). But this method will return NULL if the page layout has not been selected in the admin ...


3

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 namespace <Vendor>\Cms\Model; use Magento\Cms\Model\Page\Source\PageLayout as BasePageLayout; class PageLayout extends BasePageLayout{ public function ...


3

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 header block/container <referenceContainer name="after.body.start"> <block class="Magento\Framework\View\Element\Template" name="custom.content" ...


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