【问题标题】:Magento - display product reviews on product view pageMagento - 在产品视图页面上显示产品评论
【发布时间】:2013-10-09 12:53:44
【问题描述】:

我在将产品评论放在特定位置的主要产品视图上时遇到了困难。我可以将它们加载到内容区域,但不能加载到我需要的特定位置(在某些视图标记内)。

我有一个 local.xml,其中包含以下内容:

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

以上内容在所有其他内容之后加载评论 - 正如预期的那样,由于内容不是模板块。

我尝试在内容引用之外定义块,并将其放在相关点:

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

为了清楚起见,这里是我需要块出现在 view.phtml 中的地方:

<div class="product-collateral">
<?php foreach ($this->getChildGroup('detailed_info', 'getChildHtml') as $alias => $html):?>
    <div class="box-collateral <?php echo "box-{$alias}"?>">
        <?php if ($title = $this->getChildData($alias, 'title')):?>
        <h2><?php echo $this->escapeHtml($title); ?></h2>
        <?php endif;?>
        <?php echo $html; ?>
    </div>
<?php endforeach;?>
    <?php echo $this->getChildHtml('upsell_products') ?>
    <?php echo $this->getChildHtml('product_additional_data') ?>
    <?php echo $this->getChildHtml('reviews') ?>
</div>

不幸的是,这根本不输出任何东西。我对 Magento 还很陌生,我不知道如何实现上述目标。

【问题讨论】:

    标签: magento templates


    【解决方案1】:

    您可以尝试保留示例中的代码,并在之前或之后包含和使用该属性。 这允许您相对于该引用中的另一个块定位一个块。

    例如:&lt;block type="review/product_view_list" name="product.info.product_additional_data" as="reviews" template="review/product/view/list.phtml" before="product.description"/&gt;

    【讨论】:

    • 谢谢,但我无法让您的方法在我的上下文中起作用。基本上,我想在 view.phtml 标记中的 &lt;div class="product-collateral"&gt;&lt;/div&gt; 中添加块 - 我已经尝试过 after="product_info_additional" 但它不起作用。我已经用更多信息修改了我的问题。
    • 好的,我已经调查了这个问题。以 layout/tag.xml 为例。基本上,您需要将参考名称从“content”更改为“product.info.additional”。这将包括特定 div 中的块。之后应该很容易使用 before 和 after 属性来调整位置。
    • 成功了,谢谢!我现在还有一个相关的问题,也许你可以看看 - [*.com/questions/19277522/…
    最近更新 更多