【发布时间】:2012-10-25 14:14:09
【问题描述】:
我有一个关于我目前正在构建的 magento 项目的问题。我的产品页面有一个主图像(可配置产品)和下面的缩略图。我的代码已经到了单击缩略图将图像附加到主图像区域的阶段,但是我需要它包含的链接的 href 也附加到该 imgs url。希望这是有道理的,欢迎任何帮助。
<?php
$_product = $this->getProduct();
$_helper = $this->helper('catalog/output');
?>
<div class="grid_12 grid_spacer_bottom">
<?php
$_img = '<img id="image" class="img-left img-inlineblock responsive-img" src="'.$this->helper('catalog/image')->init($_product, 'image').'" alt="'.$this->htmlEscape($this->getImageLabel()).'" />';
//echo $_helper->productAttribute($_product, $_img, 'image');
?>
<a href=""><?php echo $_helper->productAttribute($_product, $_img, 'image'); ?></a>
</div>
<div class="clear"></div>
<?php if (count($this->getGalleryImages()) > 0): ?>
<div class="more-views">
<?php foreach ($this->getGalleryImages() as $_image): ?>
<div class="grid_4 grid_spacer_bottom">
<a href="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $_image->getFile()); ?>" title="<?php echo $_product->getName();?>" onclick="$('image').src = this.href; return false;">
<img class="img-left img-inlineblock responsive-img" src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'thumbnail', $_image->getFile()); ?>" alt="<?php echo $this->htmlEscape($_image->getLabel()) ?>" />
</a>
</div>
<?php endforeach; ?>
</div>
<?php endif; ?>
【问题讨论】:
-
我认为我已经取得了一些进展,在更新要显示为主图像的 img 的 js 上(在缩略图周围的 a 上)我试图添加更多的 js 来更新$image 的 href 并更新了构建 $image 的代码......但这仍然没有附加 imgs url。 onclick="$('image').src = this.href; return false;$('image').href = this.href; return false;"
标签: php javascript magento magento-1.7