0

現在、MagePsychojqueryライトボックスの拡張機能を使用しています。この拡張機能は、フロントエンドですべてのサムネイルを呼び出し、「その他のビュー」のサムネイルとして表示します。これらを制限したいと思います。media.phtmlのコードは次のとおりです。

`<div class="more-views">
<h2><?php echo $helper->getConfig('more_views_label') ?></h2>
<ul>
<?php foreach ($this->getGalleryImages() as $_image):
        if(empty($popUpImageSize[0]) || empty($popUpImageSize[0])):
            $popUpImage = $this->helper('catalog/image')->init($this->getProduct(),           'image', $_image->getFile());
        else:
            $popUpImage = $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile())->resize($popUpImageSize[0], $popUpImageSize[1]);
        endif;
?>
    <li>
        <a href="<?php echo $popUpImage; ?>" rel="<?php echo $rel; ?>" class="<?php echo  $class; ?>" title="<?php echo $this->htmlEscape($_image->getLabel()) ?>"><img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile())->resize($thumbnailSize[0], $thumbnailSize[1]); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" /></a>
    </li>
<?php endforeach; ?>
</ul>

`

問題を説明する画像が添付されています。ありがとうここに画像の説明を入力してください

4

1 に答える 1

1

必要な情報はすべて揃っているようです。

各画像をループするループがあります

<?php foreach ($this->getGalleryImages() as $_image):
    //output thumbnail code snipped
<?php endforeach; ?>

すべての項目をループする代わりに、4 回だけループする必要があります。これを達成するには、さまざまな方法があります。これはセンチネル値を使用したものです

<?php $c = 0; ?> //define a counter
<?php foreach ($this->getGalleryImages() as $_image):
    //output thumbnail code snipped
    <?php if($c > 3) { break; } ?> //break if we've looped four times 
    <?php $c++?>                   //increment the counter
<?php endforeach; ?>
于 2013-03-23T04:35:58.450 に答える