我可以使用PHP动态插入Pinterest的网址,媒体和描述吗?
问题描述:
Here's my code:
<script type="text/javascript">
(function() {
window.PinIt = window.PinIt || { loaded:false };
if (window.PinIt.loaded) return;
window.PinIt.loaded = true;
function async_load(){
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
if (window.location.protocol == "https:")
s.src = "https://assets.pinterest.com/js/pinit.js";
else
s.src = "http://assets.pinterest.com/js/pinit.js";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent("onload", async_load);
else
window.addEventListener("load", async_load, false);
})();
</script>
<!-- Customize and include for EACH button in the page -->
<a href="http://pinterest.com/pin/create/button/?url=<?php echo $this->helper('core/url')- >getCurrentUrl(); ?>&media=<?php echo $this->helper('catalog/image')->init($_product, 'image')->resize(500); ?>&description=<?php echo $_product->getShortDescription(); ?>" class="pin-it-button" count-layout="none">Pin It</a>
The php successfully gathers all of the elements and when I click on the button, it pops up the modal window.
However, in the subsequent modal window, it does not pin to my board when I'm logged in.
The Script tag and link are both inside of a list item.
Any help would be appreciated.
Thanks, Moises M.
这是我的代码: p>
&lt; script type =“ text / javascript“&gt;
(function(){
window.PinIt = window.PinIt || {loaded:false};
if(window.PinIt.loaded)return;
window.PinIt.loaded = true; \ nfunction async_load(){
var s = document.createElement(“script”);
s.type =“text / javascript”;
s.async = true;
if(window.location.protocol == “https:”)
s.src =“https://assets.pinterest.com/js/pinit.js";
else
s.src =”http://assets.pinterest.com/js /pinit.js";
var x = document.getElementsByTagName(“script”)[0];
x.parentNode.insertBefore(s,x);
}
if(window.attachEvent)
窗口。 attachEvent(“onload”,async_load);
else
window.addEventListener(“load”,async_load,false);
})();
&lt; / script&gt;
&lt;! - 自定义和 包含页面中的EACH按钮 - &gt;
&lt; a href =“http://pinterest.com/pin/create/button/?url=<?php echo $ this-&gt; helper('core / url') - &gt; getCurre ntUrl(); ?&gt;&amp; media =&lt;?php echo $ this-&gt; helper('catalog / image') - &gt; init($ _ product,'image') - &gt; resize(500); ?&gt;&amp; description =&lt;?php echo $ _product-&gt; getShortDescription(); ?&gt;“class =”pin-it-button“count-layout =”none“&gt; Pin It&lt; / a&gt;
code> pre>
php成功收集所有内容 当我点击按钮时,它会弹出模态窗口。 p>
但是,在后续的模态窗口中,当我登录时它不会固定到我的主板上 。 p>
脚本标记和链接都在列表项内。 p>
任何帮助都将不胜感激。 p>
谢谢,
Moises M。 p>
div>
答
From your description it sounds like the problem is that you are not url encoding the parameters, i.e. everything after the ?url=
I'm not sure if that's the only problem you'll run into with this, but it should fix the one you're currently hitting!