如何在产品页面的选项卡中显示评论表单以及评论 [英] how to display review form as well as reviews in a tab in product page

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

问题描述

可能重复:
如何在产品视图页面上添加评论标签

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

如何在产品页面的选项卡中显示评论表单以及评论. 我在catalog.xml中做了以下操作

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

推荐答案

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

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

添加带有评论的标签

<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天全站免登陆