Today we are going to see how to move elements in Magento 2.
Magento 2 is famous for releasing new functionality, features and approaches. We are going to talk about the new feature of templating.
Magento 2 offers this functionality where we can move blocks or let’s say containers to different places and that too within the page. With the help of the layout file, we can move containers & blocks.
Let’s see how to move elements in Magento 2
We can use this tiny piece of code in layout file to move containers & blocks.
<move element="name of conatiner or block" destination="destination block or container name" />
Let’s see the example. Here we are going to move price block directly at product page.
Below code will do the magic.
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <move element="product.info.price" destination="product.info.media" /> </page>
VOILA!! You see. That’s how a tiny piece of code will help us to move elements in Magento 2.