2012-06-05 18 views
-4

我有所謂的自由航運自定義屬性的Magento商店的頂部 眼下這使產品本身把圖像放在另一個PHP和HTML

下方的免費送貨圖標,但我想讓它通過在產品本身上放置一個新按鈕更具吸引力。

下面是Magento的頁面的PHP代碼:

的頁面是如何呈現的樣例: http://www.theprinterdepo.com/lexmark-optra-t640-printer-20g0100

我需要修改代碼gallery.phtml穿上頂部的圖標產品,右上角。 我將修改圖像爲透明。

這是gallery.phtml文件:

<?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> 

這是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 }?> 
+0

[你嘗試過什麼(http://mattgemmell.com/2008/12/08/what-have-you-tried/),爲什麼沒有它的工作?真正的問題是什麼,「你能爲我做好嗎?」 –

+0

PHP =服務器端。你的問題是客戶端大小,所以這與PHP無關。 –

回答

2

不知道Magento的一個偉大的交易,但你在談論需要CSS編碼不算什麼真的是PHP。理想情況下,您將需要兩個圖像輸出到相同的容器DIV。

然後將圖像設置爲position: absolute,然後使用zindex將它們堆疊在一起。注意容器div將需要爲position: absolouteposition: relative定位圖像才能正常工作。

在這裏看到更多 - How can we overlap two images using css style?