Magento 2 – How to Add Custom PHTML to Product Page

magento2product

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

Best Answer

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>