1

そこで、商品ページに商品レビューを表示する方法を見つけました。ここで、表示されるレビューの数を制限し、製品レビューのデフォルト ページに「もっとレビューを読む」リンクを追加する方法を理解する必要があります。

何か案は?または、誰かが私を正しい方向に向けることができますか? さまざまなスクリプトを試してみましたが、うまくいきませんでした。

更新:以下の変更を試みましたが、まだ機能していません - 私が間違っていることについてのアイデアはありますか?

ええ、それは私が思ったことですが、まだ機能していません。私が間違っていることはありますか??

<?php $_items = $this->getReviewsCollection()->setPageSize('5')->getItems();?>
<div class="box-collateral box-reviews" id="customer-reviews">
<?php if (count($_items)):?>
<div class="box-title">
    <h2><?php echo $this->__('Customer<br><span id="smallH2">Reviews</span>') ?></h2>
</div>
<?php echo $this->getChildHtml('toolbar') ?>
<dl class="box-content" id="product-reviews-list">
<?php foreach ($_items as $_review):?>
<dt>
<?php
$reviewURL = $this->getReviewUrl($_review->getId());
$reviewURL = str_replace("catalog","review",$reviewURL);
?>
<a href="<?php echo $reviewURL ?>"><?php echo $this->htmlEscape($_review->getTitle())            ?></a>       <?php echo $this->__('Review by <span>%s</span>', $this->htmlEscape($_review->getNickname())) ?>
</dt> 
    <dd>
        <table class="data-table review-summary-table">
            <col />
            <col />
            <tbody>
                <?php foreach ($_review->getRatingVotes() as $_vote): ?>
                <tr>
                    <th class="label"><?php echo $this->escapeHtml($_vote->getRatingCode()) ?></th>
                    <td class="value">
                        <div class="rating-box">
                            <div class="rating" style="width:<?php echo $_vote->getPercent() ?>%;">    
</div>
                        </div>
                    </td>
                </tr>
                <?php endforeach; ?>
            </tbody>
        </table>
        <p><?php echo nl2br($this->htmlEscape($_review->getDetail())) ?></p>
        <p class="date"><?php echo $this->__('(Posted on %s)',    $this->formatDate($_review->getCreatedAt()), 'long') ?></p>
    </dd>
<?php endforeach; ?>
</dl>
<script type="text/javascript">decorateGeneric($$('#product-reviews-list dd'), ['last']);</script>
<?php endif;?>
<?php echo $this->getChildHtml('review_form') ?>
</div>
4

4 に答える 4

1

これは私が最終的に行った解決策です:

<?php
$i = 1;
foreach ($_items as $_review):
    if ($i < 6): ?>

助けてくれてありがとう...

于 2012-11-21T15:30:05.123 に答える
1

私はこれをしなければならず、より堅牢な方法を見つけました。テーマのreview.xmlファイルで、ページャーを作成する次の行を見つけます。

<block type="page/html_pager" name="product_review_list.toolbar" />

それを次のように置き換えます(好きな番号を除く):

<block type="page/html_pager" name="product_review_list.toolbar">
    <action method="setLimit"><limit>6</limit></action>
</block>
于 2013-11-21T17:04:33.373 に答える
0

コレクションを使用してレビューを取得していることを願っています。だからあなたは作ることができます

$collection->setPageSize('number of reviews on page');
于 2012-10-08T16:13:51.367 に答える