php – 在magento产品页面上更新主产品网址
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php – 在magento产品页面上更新主产品网址,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1921字,纯文字阅读大概需要3分钟。
内容图文
我有一个正在建设的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; ?>
解决方法:
我假设您在点击大图时尝试制作它将具有缩略图的网址
给这个href一个ID
<a href="" id="img_href"><?php echo $_helper->productAttribute($_product, $_img, 'image'); ?></a>
你使用jquery或原型(如果默认magento然后这个)
原型
$('img_href').setAttribute('href', this.href);
//$('img_href').href = this.href; // or
jQuery的
$("#img_href").attr("href", this.href);
简单的Javascript
document.getElementById(‘img_href’).href = this.href;
点击更新缩略图
onclick="$('image').src = this.href; $('img_href').setAttribute('href', this.href); return false;"
内容总结
以上是互联网集市为您收集整理的php – 在magento产品页面上更新主产品网址全部内容,希望文章能够帮你解决php – 在magento产品页面上更新主产品网址所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。