Magento2: Add new tab on product detail page

Display Blocks Contents On Tab :
Create file catalog_product_view.xml in the NameSpace/ModuleName/view/frontend/layout/ . Below Xml will add new tab in product detail page.
<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="Magento\Catalog\Block\Product\View" name="delivery.tab" template="NameSpace_ModuleName::delivery.phtml" group="detailed_info" >
<arguments>
<argument translate="true" name="title" xsi:type="string" after="reviews">Delivery Information</argument>
<argument name="priority" xsi:type="string">3</argument>
</arguments>
</block>
</referenceBlock>
</body>
</page>

Now Create file delivery.phtml inside NameSpace/ModuleName/view/frontend/templates/ below code display blocks in tab.
<?php echo $block->getLayout()->createBlock('Magento\Cms\Block\Block')->setBlockId('product_delivery_tab')->toHtml();?>
Create Block "product_delivery_tab" from admin backend.Now check in the Detail page.

Change Position of custom Container Or Block:
<referenceContainer name="content">
 <block class="path"  name="conainer_name" as="conainer_namet" after="-" template="list.phtml"/>
</referenceContainer>

<move element="mageants.allslider.list" destination="content" after="product.info.media"/>

Comments