我試圖將"Pin it" button from Pinterest添加到我們網站上的產品詳細信息頁面。Magento:在產品詳細信息頁面添加Pinterest「Pin it」按鈕
到目前爲止,我已經試過:
<a href="http://pinterest.com/pin/create/button/?url=<?php echo trim(Mage::registry('current_product')->getProductUrl()) ?>&media;=<?php echo $this->helper('catalog/image')->init($_product, 'small_image')->resize(265) ?>&description;=<?php echo Mage::registry('current_product')->getName(); ?>" class="pin-it-button" count-layout="none">Pin It</a>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
和
<a href="http://pinterest.com/pin/create/button/?url=<?php echo trim(Mage::registry(\'current_product\')->getProductUrl()) ?>&media;=<?php echo Mage::helper('catalog/image')->init(Mage::registry('current_product'), 'small_image')->resize(900,900);?>&description;=<?php echo Mage::registry('current_product')->getName(); ?>" class="pin-it-button" count-layout="none">Pin It</a>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
與任何這些,我可以得到項目Service items的網址和產品的名字,但我不能讓產品的形象。所以,後不工作(它需要所有3項工作:URL,媒體和說明)
當我試試這個:
<a href="http://pinterest.com/pin/create/button/?url=http://eberjey.com&media;=<?php echo Mage::helper('catalog/image')->init(Mage::registry('current_product'), 'small_image')->resize(900,900);?>&description;=<?php echo Mage::registry('current_product')->getName(); ?>" class="pin-it-button" count-layout="none">Pin It</a>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
我可以發佈產品的形象,但URL不是動態(我只是使用網站的絕對URL)。
有關如何在我的產品詳細信息頁面中實現此按鈕的任何想法?
我試圖獲取當前的商品網址,但是當我使用的代碼「引腳爲」腳本沒有拿到產品形象。 如果我使用絕對URL,例如:http://domain.com,那麼腳本將獲取產品圖像。 我也試過'<?php echo $ this - > _ data ['urlKey']?>'但它仍然不起作用。 – jmanson 2012-02-01 14:01:04
@jmanson如果你不介意,可否請在這裏發佈錯誤和正確的URL樣本? – 2012-02-01 16:00:31
你檢查過pinit.js嗎?該腳本希望將網址除以'&' – 2012-02-01 16:02:01