1

How to call custom block file in custom theme in magento 2

app/code/Cm/Mod/view/frontend/layout/catalog_product_view.xml

  <?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>   
      <referenceContainer name="product.info.main">
        <block class="Cm\Mod\Block\Display"
               name="product.view.extra"
               template="Cm_Mod::product/view/extra.phtml"
              after="product.info.overview">
        </block>
    </referenceContainer>
   </body>
</page>

app/code/Cm/Mod/view/frontend/templates/product/view/extra.phtml

<p>custom block</p>

How to call a extra.phtml file in custom theme in magento 2 someone please help me

  • is the path to your file is app/code/Cm/Mod/view/forntend/layout/catalog_product_view.xml ? – surbhi agr Jun 6 at 11:51
  • s layout file is placed in above mentioned path – divya sekar Jun 6 at 11:53
  • it should be frontend not forntend – surbhi agr Jun 6 at 11:53
  • sry its a typo mistake i was corrected it in the above question – divya sekar Jun 6 at 11:55
  • can you please tell me how to call a custom block in custom theme – divya sekar Jun 6 at 11:56

Your Answer

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

Browse other questions tagged or ask your own question.