3

I have added a custom tab to a magento 2 store, however I am unable to set the position. I want it between the reviews tab and the description tab. I am able to add the tab with in the catalog_product_view.xml file, but not able to set order.

I can't seem to find any documentation on how to set order. When I try to add after="" or before="" it does not seem to make a difference.

3

This will add your tab before review tab

<referenceBlock name="product.info.details">

<block class="Magento\Catalog\Block\Product\View" name="custom.tab" as="custom" template="product/view/custom.phtml" group="detailed_info"  before ="review.tab">

<arguments>

<argument translate="true" name="title" xsi:type="string">Custom Tab</argument>

</arguments>

</block>

</referenceBlock>
3

Try using this code : -

 <referenceBlock name="product.info.details"> 

<block class="Magento\Review\Block\Product\Review" name="custom.tab" as="custom" template="Magento_Review::review.phtml" group="detailed_info" before="reviews.tab">

<block class="Magento\Review\Block\Form" name="product.review.form" >

      <container name="product.review.form.fields.before" as="form_fields_before" label="Review Form Fields Before"/>

</block>
</block> 
   </referenceBlock>

Yes it should be reviews.tab

Let me know if you still face any issues

2

Thanks for the help.

Using your block above had no difference on order of tabs. I did notice an issue with the name of the reviews block. It should be reviews.tab.

I am able to remove the tab with<referenceBlock name="reviews.tab" remove="true" /> so I know that reviews.tab block name is correct.

I also tried moving the reviews.tab using the following: <move element="reviews.tab" destination="product.info.details" after="custom.tab"/> and that did not work either.

Thanks

  • That did not work. – JonW Apr 11 '16 at 16:40
  • Here is my block with before reviews tab : – JonW Apr 11 '16 at 16:41
  • <referenceBlock name="product.info.details"> <block class="Magento\Catalog\Block\Product\View" name="custom.tab" as="custom" template="product/view/care_info.phtml" group="detailed_info" before="reviews.tab"> <arguments> <argument translate="true" name="title" xsi:type="string">Material Care</argument> </arguments> </block> </referenceBlock> – JonW Apr 11 '16 at 16:41
  • Just can't get this into the correct position. I can move the reviews block to another part of product page, but cannot make it display after custom tab inside product.info.details block. Kinda weird. – JonW Apr 11 '16 at 16:43

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.