【问题标题】:Magento: Display all images on the product page (view.phtml)Magento:在产品页面上显示所有图像(view.phtml)
【发布时间】:2015-11-23 23:57:35
【问题描述】:

我可以通过 $this->getGalleryImages() 看到 media.phtml(带有 Cloud Zoom 扩展)如何列出产品页面上的所有图像:

<?php foreach ($this->getGalleryImages() as $_image): ?>
<?php ... ?>
<?php endforeach; ?>

但是当我在目录产品页面模板 view.phtml 中使用 $this->getGalleryImages() 时,它不会返回或输出任何内容。但是,这只会打印产品页面上的第一张图片:

<img src="<?php echo $this->helper('catalog/image')->init($_product, 'image')->constrainOnly(TRUE)->keepAspectRatio(TRUE)->keepFrame(FALSE)->setWatermarkImageOpacity(0)->resize(300, null);?>" alt="<?php echo $this->htmlEscape($this->getImageLabel());?>" title="<?php echo $this->htmlEscape($this->getImageLabel());?>" />

我的问题是如何遍历并显示产品页面上的所有产品图像(view.phtml,而不是 media.phtml)?基本上,我希望它们全部显示在页面上,而不需要缩略图或缩放或任何东西,只是简单的大图像,一个接一个。

谢谢!

【问题讨论】:

    标签: magento


    【解决方案1】:

    这是显示产品图片库的代码..

    谢谢, 吉特

    <?php $_images = Mage::getModel('catalog/product')->load($_product->getId())->getMediaGalleryImages(); ?>
    <?php if($_images){?>            
        <?php $i=0; foreach($_images as $_image){ $i++; ?>
            <img src="<?php echo $this->helper('catalog/image')->init($_product, 'thumbnail', $_image->getFile())->resize(108,90); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel());?>" title="<?php $this->htmlEscape($_image->getLabel());?>" /><?php } ?>
        <?php } ?>
    

    【讨论】:

      猜你喜欢
      • 2016-05-11
      • 2013-01-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多