如何在产品查看页面上添加评论选项卡 [英] How to add review tab on product view page

查看:39
本文介绍了如何在产品查看页面上添加评论选项卡的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Magento的初学者.我想在产品视图"页面中添加评论"选项卡. 有人可以帮我怎么做吗?

I am a beginner in Magento. I want to add a Review Tab in product view page. Can anyone help me how to do this?

我尝试了以下方法:

<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>additional</alias><title>General Info</title><block>catalog/product_view_attributes</block><template>catalog/product/view/attributes.phtml</template></action-->
                    <action method="addTab" translate="title" module="catalog"><alias>description</alias><title>Description</title><block>catalog/product_view_description</block><template>catalog/product/view/description.phtml</template></action>
                    <action method="addTab" translate="title" module="catalog"><alias>upsell</alias><title>Upsell</title><block>catalog/product_list_upsell</block><template>catalog/product/list/upsell.phtml</template></action>
                    <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>
                    <action method="addTab" translate="title" module="catalog"><alias>additional</alias><title>Additional Information</title><block>catalog/product_view_attributes</block><template>catalog/product/view/attributes.phtml</template></action>

    </block>

然后在view.phtml中使用echo $this->getChildHtml('info_tabs');.

Then using echo $this->getChildHtml('info_tabs'); in view.phtml.

仅可见描述,评论和其他信息. 可能是什么问题? 谢谢

Only description, review and additional information are visible. What may be the problem? Thanks

推荐答案

这是我来自这是我在其中一个项目中处理这种情况的方式:

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

添加带有评论的标签,

<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>

现在,审阅表单由不同类型的模块处理,该模块通常是审阅页面的子模块.无法通过addTab动作制作嵌套块,但是可以在如下所示的选项卡中创建审阅块之后使用<reference>处理程序:

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>

<reference>处理程序中的

name必须等于addTab动作中<alias>中的内容.

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

catalog/product/view/tabs/reviews.phtml中,您只需使用

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

您可以使用<reference>处理程序向查看列表和查看表单添加更多块.

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

当然,您必须在template参数中输入的路径中创建用于审阅列表和审阅表单的文件,因此在这种情况下,您将需要创建catalog/product/view/tabs/reviews.phtmlcatalog/product/view/tabs/review_form.phtml.您可以将审阅表单模板更改为默认的review/form.phtml.如果您不需要在那里更改代码,或者仅在该选项卡中使用它,但是审阅列表可能需要对html结构进行更多更改,因此最好创建单独的表单文件并根据需要使用部分默认代码.

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.

这篇关于如何在产品查看页面上添加评论选项卡的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆