想在产品页面magento的侧边栏中显示产品评论吗
我想在magento的产品页面的侧栏中显示产品的最新评论(可能是3或4) 显示评论的前10或15个单词,星型栏和评论页面的链接以查看所有评论 非常感谢您的任何建议或建议 谢谢 约翰尼想在产品页面magento的侧边栏中显示产品评论吗,magento,sidebar,review,Magento,Sidebar,Review,我想在magento的产品页面的侧栏中显示产品的最新评论(可能是3或4) 显示评论的前10或15个单词,星型栏和评论页面的链接以查看所有评论 非常感谢您的任何建议或建议 谢谢 约翰尼 我将创建一个扩展 使用layout.xml将应该扩展核心/模板块的块放在产品页面的左/右侧栏中 在该块类中,您应该具有从数据库检索要显示的评论的方法。例如,假设您需要一个getReviews()方法 在模板中,调用$this->getReviews()并迭代结果,然后根据需要显示评论。星型条可能有点麻烦,但如果您查
- 我将创建一个扩展
- 使用layout.xml将应该扩展核心/模板块的块放在产品页面的左/右侧栏中
- 在该块类中,您应该具有从数据库检索要显示的评论的方法。例如,假设您需要一个getReviews()方法
- 在模板中,调用$this->getReviews()并迭代结果,然后根据需要显示评论。星型条可能有点麻烦,但如果您查看使用它们的其他模板文件,您应该能够了解其要点:)
HTH:)正如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/[你的主题]/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;?>
正如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/[你的主题]/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;?>