I can't able to add/include my custom phtml file on product detailed page.
Here is my entire flow :
Added the following code in app/design/frontend/Themename/themedirectory/Magento_Catalog/layout/catalog_product_view.xml file
<body> <referenceContainer name="content"> <container name="product-main-content" htmlTag="div" htmlClass="product-main-content" before="-"> </container> </referenceContainer> <referenceContainer name="content.top.most"> <container name="custom.block.sec" htmlTag="div" htmlClass="custom-class" before="-"> <block class="Magento\Catalog\Block\Product\View" name="my_custom" template="Vendorname_Modulename::custom.phtml" /> </container> </referenceContainer> <block class="Magento\Theme\Block\Html\Title" name="page.main.sub.title" template="Magento_Theme::html/title.phtml"/> <referenceBlock name="product.info.details"> <block class="Magento\Catalog\Block\Product\View" name="cmsinfo.tab" as="cmsinfo" template="product/view/cms_tab.phtml" group="detailed_info" > <arguments> <argument translate="true" name="title" xsi:type="string">Custom Tab</argument> </arguments> </block> </referenceBlock> <move element="custom.block.sec" destination="product.info.main" before="-"/> </body>Added the custom.phtml file in app/code/Vendorname/Modulename/view/frontend/templates/custom.phtml
custom.phtml file content
Custom File Works
I referred this link as well but no luck.
But its not working. Why?
Can anyone let me know what's the issue & how to add the custom file in product page?
-
I've edited for you :)Aasim Goriya– Aasim Goriya2019年01月23日 09:20:41 +00:00Commented Jan 23, 2019 at 9:20
1 Answer 1
Please try this way in your app/design/frontend/Themename/themedirectory/Magento_Catalog/layout/catalog_product_view.xml file
<referenceContainer name="content.top.most">
<container name="custom.block.sec" htmlTag="div" htmlClass="custom-class" before="-">
<block class="Magento\Catalog\Block\Product\View" name="my_custom" template="Vendorname_Modulename::custom.phtml" />
</container>
</referenceContainer>
<move element="custom.block.sec" destination="product.info.main" before="-"/>
After that please check with clear your cache.
-
Thanks for your answer, I just tried the code but its not working. I have updated my entire code in question. Please check itMesk– Mesk2019年01月23日 09:41:43 +00:00Commented Jan 23, 2019 at 9:41
-
did you clear cache after this changes ?Aasim Goriya– Aasim Goriya2019年01月23日 09:43:56 +00:00Commented Jan 23, 2019 at 9:43
-
Yes cleared cache by php bin/magento cache:flush and php bin/magento cache:clean But its not workingMesk– Mesk2019年01月23日 09:47:51 +00:00Commented Jan 23, 2019 at 9:47
-
its strange, because its working fine for me. can you please check your custom module name is Vendorname_Modulename which is correct ?Aasim Goriya– Aasim Goriya2019年01月23日 09:49:41 +00:00Commented Jan 23, 2019 at 9:49
-
1@Mesk clear your cache and refresh cache from admin and once check.Rizwan Khan– Rizwan Khan2019年01月23日 10:09:44 +00:00Commented Jan 23, 2019 at 10:09
Explore related questions
See similar questions with these tags.