希望在产品页面magento的侧边栏中显示产品评论

时间:2011-06-27 12:31:14

标签: magento sidebar review

我希望在magento的产品页面的侧边栏中显示产品(可能是3或4)的最新评论。

显示评论的前10或15个字,星条和评论页面的链接以查看所有评论..

任何建议或指示非常感谢,

谢谢,

约翰尼

2 个答案:

答案 0 :(得分:4)

正如ElGabby所说,创建扩展将是可行的方法。

但您可以通过编辑当前布局来完成此操作。

转到/ app / design / frontend / default / [your theme] / layout /或/ app / design / frontend / base / [your theme] / layout /

中的文件catalog.xml

找到该部分:

<catalog_product_view>

在那里你可以有一个像:

这样的部分
<reference name="right">

在该部分添加:

<block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />

我的示例中的部分如下所示:

<reference name="right">
        <block type="review/product_view" name="right.rewiev" template="review/rightbar.phtml" />
        <block type="catalog/product_list_related" name="catalog.product.related" before="-" template="catalog/product/list/related.phtml"/>
    </reference>

保存文件并在以下位置创建新文件: / app / design / frontend / default / [your theme] /design/review/rightbar.phtml

该文件的内容如下:

<?php $collection = $this->getReviewsCollection(); ?>
<?php if(count($collection) > 0):?>
<?php foreach ($collection as $rating):?>

    <?php echo $rating->title //title of the rewiev?>

    <?php echo $rating->detail //content of the rewiev?>
    <?php echo $rating->created_at //data rewiev is created?>
<?php endforeach;?>
<?php endif;?>

答案 1 :(得分:1)

  • 我会创建一个扩展名。
  • 使用layout.xml放置应在产品页面的左/右侧边栏中扩展核心/模板块的块
  • 在该块类中,您应该拥有将从数据库中检索您希望显示的评论的方法。所以说比如说你需要一个方法getReviews()
  • 在模板中调用$ this-&gt; getReviews()并迭代结果并根据需要显示评论。星条可能有点麻烦但是如果你看一下使用它们的其他模板文件,你应该能够得到它的要点:)

HTH:)

相关问题