显示评分高于评论

时间:2016-07-07 12:35:34

标签: php

我们使用以下代码显示评论&评级部分。我想在上面显示明星"标题":This is really very good product

enter image description here

<?php $_items = $this->getReviewsCollection()->getItems();?>
<div class="box-collateral box-reviews" id="customer-reviews">
    <?php if (count($_items)):?>
        <div class="review-heading">
            <h2>
                <?php echo $this->__('') ?>
                <span class="reviewtab">
                <?php 
            //  echo count($_items); 
                ?> 
                Ratings & Reviews
                </span>
            </h2>
            <?php echo $this->getChildHtml('toolbar') ?>
        </div>
        <dl>
        <?php foreach ($_items as $_review):?>

            <dt>
                <a href="<?php echo $this->getReviewUrl($_review->getId()) ?>">
                    <?php echo $this->escapeHtml($_review->getTitle()) ?>
                </a>
            </dt>
            <dd>
                <?php $_votes = $_review->getRatingVotes(); ?>

                <?php echo nl2br($this->escapeHtml($_review->getDetail())) ?>


                <?php if (count($_votes)): ?>
                <table class="ratings-table">
                    <colgroup>
                        <col class="review-label" />
                        <col class="review-value" />
                    </colgroup>
                    <tbody>
                        <?php foreach ($_votes as $_vote): ?>
                        <tr>
                            <th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
                            <td>
                                <div class="rating-box">
                                    <div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
                                </div>
                            </td>
                        </tr>
                        <?php endforeach; ?>
                    </tbody>
                </table>
                <?php endif; ?>


                <span class="review-meta">
                    <?php echo $this->__('Review by %s', $this->escapeHtml($_review->getNickname())) ?>
                    /
                   <?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?>
                </span>
            </dd>
        <?php endforeach; ?>
        </dl>

        <?php // echo $this->getChildHtml('toolbar') ?>
    <?php elseif($this->getParentBlock()): ?>
        <?php echo $this->getParentBlock()->getReviewsSummaryHtml($this->getProduct(), 'short', true)?>
    <?php endif;?>
    <?php echo $this->getChildHtml('review_form') ?>
</div>

当我尝试使用CSS时,它对我没用。

我尝试交换代码,但它对我也没有用。我交换错误了吗?

请帮我找到解决方案。

提前致谢

1 个答案:

答案 0 :(得分:1)

这应该有帮助,你可能需要做一些微小的css改变。

<?php $_items = $this->getReviewsCollection()->getItems();?>
<div class="box-collateral box-reviews" id="customer-reviews">
<?php if (count($_items)):?>
    <div class="review-heading">
        <h2>
            <?php echo $this->__('') ?>
            <span class="reviewtab">
            <?php 
        //  echo count($_items); 
            ?> 
            Ratings & Reviews
            </span>
        </h2>
        <?php echo $this->getChildHtml('toolbar') ?>
    </div>
    <dl>
    <?php foreach ($_items as $_review):?>

        <dt>
        <?php $_votes = $_review->getRatingVotes(); ?>
            <?php if (count($_votes)): ?>
            <table class="ratings-table">
                <colgroup>
                    <col class="review-label" />
                    <col class="review-value" />
                </colgroup>
                <tbody>

                    <?php foreach ($_votes as $_vote): ?>
                    <tr>
                        <th><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
                        <td>
                            <div class="rating-box">
                                <div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;"></div>
                            </div>
                        </td>
                    </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
            <?php endif; ?>
            <a href="<?php echo $this->getReviewUrl($_review->getId()) ?>">
                <?php echo $this->escapeHtml($_review->getTitle()) ?>
            </a>
        </dt>
        <dd>

            <?php echo nl2br($this->escapeHtml($_review->getDetail())) ?>




            <span class="review-meta">
                <?php echo $this->__('Review by %s', $this->escapeHtml($_review->getNickname())) ?>
                /
               <?php echo $this->__('(Posted on %s)', $this->formatDate($_review->getCreatedAt()), 'long') ?>
            </span>
        </dd>
    <?php endforeach; ?>
    </dl>

    <?php // echo $this->getChildHtml('toolbar') ?>
<?php elseif($this->getParentBlock()): ?>
    <?php echo $this->getParentBlock()->getReviewsSummaryHtml($this->getProduct(), 'short', true)?>
<?php endif;?>
<?php echo $this->getChildHtml('review_form') ?>