0

I have created a phtml file which I want to add to my product pages.

I know that there are two containers at the top which are product.info.media and product.info.main. Then there is product.info.details, the area where the tabs are and the description starts (product.info.description).

My problem: I can't reference the exact spot where I want to place my block. It is supposed to be displayed just between the two div classes product media and product info detailed.

I have tried

<referenceContainer name="product.info.media">
    <container name="product.info.afterprice" after="-" label="Product info afterprice" htmlTag="div" htmlClass="product-info-after-price">
        <block class="Magento\Framework\View\Element\Template" name="product-extra"  template="Magento_Theme::html/added/product-extra.phtml" />
    </container>
</referenceContainer>

OR

<move element="product.info.afterprice" destination="product.info.details" before="-" />

but never shows where I want it to be. How can I reference the main product content area and say after="product.info.media" or before="product.info.details"?

1
  • Did you check with my code? Commented Feb 5, 2019 at 5:24

2 Answers 2

1

Add below code to app/design/frontend/{{vendor}}/{{companyname}}/Magento_Catalog/layout/catalog_product_view.xml file

<referenceContainer name="content">
    <block class="Magento\Framework\View\Element\Template" after="product.info.media" name="product-extra" template="Magento_Theme::html/added/product-extra.phtml"/>
</referenceContainer>

If you will add my solution on your catalog_product_view.xml file then you will not required to move it.

1
  • i diid this but tits going after product tabs
    – Waqar Ali
    Commented Dec 26, 2019 at 12:57
0
<referenceContainer name="content">
    <container name="product.info.test" htmlTag="div" htmlClass="product test" after="product.info.media">
        <block class="Magento\Framework\View\Element\Template" name="product-extra" template="Magento_Theme::html/added/product-extra.phtml" />
    </container>
</referenceContainer>
1
  • That did not change anything and made the block disappear...
    – TheFrakes
    Commented Feb 5, 2019 at 10:36

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.