3

I'm trying to wrap the .product-info-main div on the product page inside a new container div (.product-info-container). After following the Magento layout instructions, it's not behaving as expected. Here's what I have in catalog_product_view.xml right now:

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceContainer name="content">
            <container name="product.info.container" htmlTag="div" htmlClass="product-info-container" before="-"/>
            <move element="product.info.main" destination="product.info.container"/>
        </referenceContainer>
    </body>
</page>

The layout doesn't change at all. However, if I remove the <referenceContainer> level, then it works as expected, but the .product-info-container div is inserted at the bottom of the page.

2
  • 1
    Try putting the 'move ' outside the referenceContainer? Commented Oct 20, 2016 at 10:31
  • @WilliamOakley That fixed it -- thanks :). If you post that as an answer, I will accept it.
    – thdoan
    Commented Oct 20, 2016 at 10:36

2 Answers 2

9

Put the 'move' outside the referenceContainer

<?xml version="1.0"?>
<page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <move element="product.info.main" destination="product.info.container"/>
        <referenceContainer name="content">
            <container name="product.info.container" htmlTag="div" htmlClass="product-info-container" before="-"/>            
        </referenceContainer>
    </body>
</page>
2
  • Is it possible to move one specific section to top of the page, i am using store-locator-m2.magento-demo.amasty.com/amlocator/summercenter if add description all are coming below the map, i need only one section the slider should be come to the top I mean right after breadcrumbs. i.sstatic.net/LbUIo.png, i am using page builder for creating description.
    – zus
    Commented Apr 1, 2021 at 12:03
  • @zus Take a look at the layout files within the extension. This will let you know which blocks are being placed where and then you should be able to move them. Otherwise you may be able to override the template files to get what you need. Commented Apr 3, 2021 at 12:06
1

Try this one:

<?xml version="1.0"?>
    <page layout="1column" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
        <body>
            <move element="product.info.main" destination="product.info.container"/>
            <referenceContainer name="content">
                <container name="product.info.container" htmlTag="div" htmlClass="product-info-container" before="-"/>            
            </referenceContainer>
        </body>
    </page>
2
  • Thanks, Nikunj Vadariya. William Oakley actually provided the answer first in the comment above, so as a courtesy I'll wait for him to post his comment as an answer. If he doesn't bother after a day, I'll accept your answer.
    – thdoan
    Commented Oct 20, 2016 at 10:50
  • oh ok Np :) @10basetom Commented Oct 20, 2016 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.