Question

Possible Duplicate:
how to add review tab on product view page

How to display review form as well as reviews in a tab in product page . I was doing the following in catalog.xml

<!--action method="addTab" translate="title" module="catalog"><alias>review</alias><title>Review</title><block>review/product_view_list</block><template>review/product/view/list.phtml</template></action--> <!--For getting the review datails-->

<action method="addTab" translate="title" module="catalog"><alias>review</alias><title>Review</title><block>review/form</block><template>review/form.phtml</template></action>  <!--For displaying review form-->

Was it helpful?

Solution

This is how I handled this situation in one of my projects:

Add tab with reviews

<block type="catalog/product_view_tabs" name="product.info.tabs" as="info_tabs" template="catalog/product/view/tabs.phtml" >
    <action method="addTab" translate="title" module="catalog"><alias>tab_review_list</alias><title>Product Reviews</title><block>review/product_view_list</block><template>catalog/product/view/tabs/reviews.phtml</template></action>
</block>

Now, the review form is handled by the different type of block which normally is a sub-block of review page. There is no way to make nested block with addTab action but you can use <reference> handler after creating review block in tabs like this:

<reference name="tab_review_list">
  <block type="review/form" name="tab_review_form" as="review_form" template="catalog/product/view/tabs/review_form.phtml" />
</reference>

name in <reference> handler must be equal to what is in <alias> in addTab action

And in catalog/product/view/tabs/reviews.phtml you just use

    echo $this->getChildHtml('review_form');

You can use <reference> handler to add more block to review list and review form.

Of course, you have to create files for review list and review form in the paths entered in template argument, so in this case you would need to create catalog/product/view/tabs/reviews.phtml and catalog/product/view/tabs/review_form.phtml. You can change review form template to the default one review/form.phtml if you do not need change the code there or you will be using it only in that tab but review list might need more changes in html structure so it is good idea to create separate file for it and use parts of the default code as needed.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top