php – 在magento产品页面上更新主产品网址
发布时间:2020-12-13 16:18:54 所属栏目:PHP教程 来源:网络整理
导读:我有一个正在建设的magento项目的问题.我的产品页面有一个主图像(可配置产品)和下面的缩略图.我已将我的代码放到舞台上,点击缩略图将图像附加到主图像区域,但是我需要包含它的链接的href也附加到该imgs URL.希望这是有道理的,欢迎任何帮助. ?php $_product =
我有一个正在建设的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,'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,'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;" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |