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

发布于 2024-11-17 08:36:29 字数 145 浏览 2 评论 0原文

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

显示评论的前 10 或 15 个单词、星形栏和评论页面的链接以查看所有评论..

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

谢谢,

约翰尼

I'm looking to show the most recent reviews for a product (maybe 3 or 4) in the sidebar on that products page in magento.

Showing the first 10 or 15 words of the review, the star bar and a link to the reviews page to see all the reviews..

any advice or pointers greatly appreciated,

Thanks,

Johnny

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

时光匆匆的小流年 2024-11-24 08:36:29

正如 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;?>

As ElGabby said, creating a extension would be the way to go.

But you can do this by editing your current layout.

Go to the file catalog.xml in /app/design/frontend/default/[your theme]/layout/ or /app/design/frontend/base/[your theme]/layout/

find the section:

<catalog_product_view>

in there you proberly have a section like:

<reference name="right">

in that section add:

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

the section in my example look like this:

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

save the file and create a new file in:
/app/design/frontend/default/[your theme]/design/review/rightbar.phtml

content of that file would be something like:

<?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;?>
清秋悲枫 2024-11-24 08:36:29
  • 我会创建一个扩展。
  • 使用layout.xml 将应扩展核心/模板块的块放置在产品页面的左/右侧边栏中。
  • 在该块类中,您应该具有从数据库检索您希望显示的评论的方法。举例来说,您需要一个方法 getReviews()
  • 在模板中调用 $this->getReviews() 并迭代结果并根据需要显示评论。星形栏可能有点麻烦,但如果您查看使用它们的其他模板文件,您应该能够理解它的要点:)

HTH :)

  • I would create an extension.
  • Using layout.xml place your block that should extend core/template block in left/right sidebar of the product page
  • Within that block class you should have methods that will retrieve from the database the reviews you wish to display. So say for instance you would need a method getReviews()
  • In the template call $this->getReviews() and iterate the result and display the reviews as you would like. The star bar might be a bit of a hassle but if you look at other template files where they are used you should be able to get the gist of it :)

HTH :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文