1

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.

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

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>
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>
  • 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 Oct 20 '16 at 10:50
  • oh ok Np :) @10basetom – Nikunj Vadariya Oct 20 '16 at 10:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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