doushang9172 2012-06-05 14:10
浏览 16
已采纳

使用php和html将图像放在另一个图像上

I have a magento store with a custom attribute called free shipping Right now this renders a free shipping icon below the product itself

But I want to make it more appealing by putting a new button on top of the product itself.

Here is the php code for the magento page:

Sample of how a page is rendered: http://www.theprinterdepo.com/lexmark-optra-t640-printer-20g0100

I need to modify the code in gallery.phtml to put the icon on TOP of the product, RIGHT top corner. I will modify the image to be transparent.

This is gallery.phtml file:

<?php $_width=$this->getImageWidth() ?>
<div class="product-image-popup" style="width:<?php echo $_width; ?>px;">
    <p class="a-right"><a href="#" onclick="window.close(); return false;"><?php echo $this->__('Close Window') ?></a></p>
    <?php if($this->getPreviusImageUrl() || $this->getNextImageUrl()): ?>
        <div class="nav">
          <?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
              <a href="<?php echo $_prevUrl ?>">&laquo; <?php echo $this->__('Prev') ?></a>
          <?php endif; ?>
          <?php if($_nextUrl = $this->getNextImageUrl()): ?>
              <a href="<?php echo $_nextUrl ?>"><?php echo $this->__('Next') ?> &raquo;</a>
          <?php endif; ?>
        </div>
    <?php endif; ?>
    <?php if($_imageTitle = $this->htmlEscape($this->getCurrentImage()->getLabel())): ?>
        <h1 class="image-label"><?php echo $_imageTitle ?></h1>
    <?php endif; ?>
    <img src="<?php echo $this->helper('catalog/image')->init($this->getProduct(), 'image', $this->getImageFile()); ?>"<?php if($_width): ?> width="<?php echo $_width ?>"<?php endif; ?> alt="<?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?>" title="<?php echo $this->htmlEscape($this->getCurrentImage()->getLabel()) ?>" id="product-gallery-image" class="image" />
    <?php if($this->getPreviusImageUrl() || $this->getNextImageUrl()): ?>
        <div class="nav">
          <?php if($_prevUrl = $this->getPreviusImageUrl()): ?>
              <a href="<?php echo $_prevUrl ?>">&laquo; <?php echo $this->__('Prev') ?></a>
          <?php endif; ?>
          <?php if($_nextUrl = $this->getNextImageUrl()): ?>
              <a href="<?php echo $_nextUrl ?>"><?php echo $this->__('Next') ?> &raquo;</a>
          <?php endif; ?>
        </div>
    <?php endif; ?>
    <p class="a-right"><a href="#" onclick="window.close(); return false;"><?php echo $this->__('Close Window') ?></a></p>
</div>
<script type="text/javascript">
//<![CDATA[
Event.observe(window, 'load', function(){
    var demensions = $('product-gallery-image').getDimensions();
    window.resizeTo(demensions.width+90, demensions.height+210);
});
//]]>
</script>

This is view.phtml

<?php $Deal = $_product->getResource()->getAttribute('deal')->getFrontend()->getValue($_product);?>
                                                <?php $onSale = $_product->getResource()->getAttribute('on_sale')->getFrontend()->getValue($_product);?>
                                                <?php $hotItem = $_product->getResource()->getAttribute('hot_item')->getFrontend()->getValue($_product);?>
                                                <?php $freeShip = $_product->getResource()->getAttribute('free_shipping')->getFrontend()->getValue($_product);?>
                                                <?php if($Deal == 'Yes'){ ?>
                                                    <img src="<?php echo $this->getSkinUrl('images/depot/icon-deal.gif') ?>" >
                                                <?php } ?>
                                                <?php if($onSale == 'Yes'){ ?>
                                                    <img src="<?php echo $this->getSkinUrl('images/depot/icon-sale.gif') ?>" >
                                                <?php } ?>
                                                <?php if($hotItem == 'Yes'){ ?>
                                                    <img src="<?php echo $this->getSkinUrl('images/depot/icon-hot.gif') ?>" >
                                                <?php } ?>
                                                <?php if($freeShip == 'Yes'){ ?>
                                                    <img src="<?php echo $this->getSkinUrl('images/depot/icon-freeship.gif') ?>" >
                                                <?php }?>
  • 写回答

1条回答 默认 最新

  • dtpwra8456 2012-06-05 14:55
    关注

    Don't know a great deal about Magento but what you are talking about will require CSS coding not really PHP. Ideally you will need both images output to the same container DIV.

    Then set the images to position: absolute and then use zindex to stack them on top of each other. Note the container div will either need to be position: absoloute or position: relative for the positioning of the images to work properly.

    See here for more - How can we overlap two images using css style?

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度