nsdlfefinedieicbe nsdlfefinedieicbe - 4 months ago 14
PHP Question

Display rating above Reviews

We are using following code for displaying review & ratings section. I want to display stars above "Title":

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>


When I tried with css, it didn't work for me.

I tried swapping code, but it didn't work for me either. Am I doing a mistake by swapping?

Please help me to find solution.

Thanks in advance

Answer

This should help, you might need to make minor css changes i think.

<?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') ?>

Comments