您的位置:首页 > 其它

magento -- 怎么把评论显示到产品页面

2012-04-01 17:17 597 查看
magento -- 怎么把评论显示到产品页面 Magento默认的评论填写和显示都是需要从产品页点击到另一个页面,怎么把提交评论的表单和评论的显示都拿到产品页来也算是一个古老的问题了,相信很多人都知道怎么操作了,不过也还是经常有刚接触Magento的人提到这个问题,今天就描述下流程(以1.4.1.1为例)。

打开/app/design/frontend/default/your_theme/layout/review.xml,复制如下代码

[xhtml] view plaincopyprint?

<block type="page/html_pager" name="product_review_list.toolbar" />

<block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml" />

<block type="review/product_view_list" name="product.info.product_additional_data" as="product_additional_data" template="review/product/view/list.phtml">

<block type="review/form" name="product.review.form" as="review_form">

<block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before">

<action method="setMayBeInvisible"><value>1</value></action>

</block>

</block>

</block>

打开/app/design/frontend/default/your_theme/layout/catalog.xml,找到

<!--

Product view

-->

粘贴刚才复制的代码到

<block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">

这个Block内部,因为product_additional_data这个Block名在产品页已经被使用,所以为了避免冲突我把评论这个Block的as改为product_review

[xhtml] view plaincopyprint?

<block type="catalog/product_view" name="product.info.options.wrapper.bottom" as="product_options_wrapper_bottom" template="catalog/product/view/options/wrapper/bottom.phtml" translate="label">

<label>Bottom Block Options Wrapper</label>

<action method="insert"><block>product.tierprices</block></action>

<block type="catalog/product_view" name="product.clone_prices" as="prices" template="catalog/product/view/price_clone.phtml"/>

<action method="append"><block>product.info.addtocart</block></action>

</block>

<!--Alex -->

<block type="page/html_pager" name="product_review_list.toolbar" />

<block type="core/template" name="product_review_list.count" template="review/product/view/count.phtml" />

<block type="review/product_view_list" name="product.info.product_additional_data" as="product_review" template="review/product/view/list.phtml">

<block type="review/form" name="product.review.form" as="review_form">

<block type="page/html_wrapper" name="product.review.form.fields.before" as="form_fields_before">

<action method="setMayBeInvisible"><value>1</value></action>

</block>

</block>

</block>

<!--Alex -->

<block type="core/template_facade" name="product.info.container1" as="container1">

<action method="setDataByKey"><key>alias_in_layout</key><value>container1</value></action>

<action method="setDataByKeyFromRegistry"><key>options_container</key><key_in_registry>product</key_in_registry></action>

<action method="append"><block>product.info.options.wrapper</block></action>

<action method="append"><block>product.info.options.wrapper.bottom</block></action>

</block>

最后一步,打开/app/design/frontend/default/your_theme/template/catalog/product/view.phtml,在适当的位置调用刚才的Block,我现在把它加到最后面

[xhtml] view plaincopyprint?

<?php echo $this->getChildHtml('upsell_products') ?>

<?php echo $this->getChildHtml('product_additional_data') ?>

<!--Alex -->

<?php echo $this->getChildHtml('product_review') ?>

<!--Alex -->

完成,缓存开着的话记得要刷新下缓存。效果如下
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: