8

In magento 2,

I want to add my custom phtml to product view page how can i add that

i want to add that phtml as tab like review or Description.

i am trying this code:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="3columns"     xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
<body>
    <referenceContainer name="product.info.details">
        <block class="Example\Examples\Block\Question" name="example.tab" template="Example_Examples::success.phtml">
        </block>
    </referenceContainer>
</body>
</page>

its give 404 error

9

Try This code.

You have to add group="detailed_info" For Create tab like review or detail

<?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="product.info.details">
        <block class="Example\Examples\Block\Question" name="example.tab" template="Example_Examples::success.phtml" group="detailed_info">
            <arguments>
                <argument translate="true" name="title" xsi:type="string">Your Title</argument>
            </arguments>
        </block>
    </referenceBlock>
  </body>
</page>
| improve this answer | |
  • I also in a same need. And I'm very new to M2. Please can you share the other steps I should follow to achieve this ? – Ajith Aug 31 '16 at 3:14
4

You can try below code,,Your phtml file content will display near social icon,,You can change referenceBlock name if you want to change position

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="2columns-left" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>        
        <referenceBlock name="product.info.social">
            <block class="Example\Examples\Block\Question" name="example.tab" template="Example_Examples::success.phtml">
            </block>
        </referenceBlock>
    </body>
</page>
| improve this answer | |
  • i want to add that phtml as tab like review or Description – Newbie Dec 15 '15 at 8:37

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.