【问题标题】:Review in Magento product pageMagento 产品页面中的评论
【发布时间】:2016-05-16 15:46:11
【问题描述】:

我正在尝试让评论提交框显示在产品页面中,显示其下的最新评论。

所有教程都说相同,但它不会工作。有什么想法吗?

catalog.xml - 在这个 sn-p 中你可以看到我已经包含了对评论的引用

 <catalog_product_view translate="label">



        <label>Catalog Product View (Any)</label>
        <!-- Mage_Catalog -->




        <reference name="root">


            <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
        </reference>
        <reference name="head">
            <action method="addJs"><script>varien/product.js</script></action>
            <action method="addJs"><script>varien/configurable.js</script></action>

            <action method="addItem"><type>js_css</type><name>calendar/calendar-win2k-1.css</name><params/><!--<if/><condition>can_load_calendar_js</condition>--></action>
            <action method="addItem"><type>js</type><name>calendar/calendar.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
            <action method="addItem"><type>js</type><name>calendar/calendar-setup.js</name><!--<params/><if/><condition>can_load_calendar_js</condition>--></action>
        </reference>
        <reference name="content">

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

            <block type="catalog/product_view" name="product.info" template="catalog/product/view.phtml">
                <!--
                <action method="addReviewSummaryTemplate"><type>default</type><template>review/helper/summary.phtml</template></action>
                <action method="addReviewSummaryTemplate"><type>short</type><template>review/helper/summary_short.phtml</template></action>
                <action method="addReviewSummaryTemplate"><type>...</type><template>...</template></action>
                -->
                <block type="catalog/product_view_media" name="product.info.media" as="media" template="catalog/product/view/media.phtml"/>
                <block type="core/text_list" name="alert.urls" as="alert_urls" translate="label">
                    <label>Alert Urls</label>
                </block>

然后在我希望它出现的目录/产品/view.phtml 中调用它:

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

【问题讨论】:

    标签: php xml magento review catalog


    【解决方案1】:

    在 catalog/product/view.phtml 试试这个:

    <div>
        <?php echo $this->getLayout()->createBlock('review/product_view_list')->setTemplate('review/product/view/list.phtml')->toHtml() ?>
    </div>        
    <div>   
        <?php echo $this->getLayout()->createBlock('review/form')->setBlockId('product.review.form')->toHtml() ?>
    </div>
    

    【讨论】:

      【解决方案2】:

      如果您想在 products view.phtml 模板中显示评论,您需要将评论列表添加为适当块的子项。应该是目录/产品视图...(不是内容)。所以在你的例子中:

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

      那么&lt;?php echo $this-&gt;getChildHtml('reviews') ?&gt; 就可以了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-06-30
        • 1970-01-01
        • 2012-09-28
        • 1970-01-01
        • 2013-08-28
        • 1970-01-01
        • 2017-09-06
        • 1970-01-01
        相关资源
        最近更新 更多