We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

How to integrate Pinterest with EE

Development and Programming

Coastal Pet Rescue's avatar
Coastal Pet Rescue
53 posts
14 years ago
Coastal Pet Rescue's avatar Coastal Pet Rescue

We are wanting to add the Pinterest shares to our website, but seem to be having some difficulty trying to make it work dynamically. Anyone else using this yet?

The way it is set up, the code wants you to manually put in the link of the webpage as well as the link for the image. They have a form that creates the code for you, but not for dynamic content.

http://pinterest.com/about/goodies/

I’m trying to use it here: http://coastalpetrescue.org/adopt/adopt-a-dog

Ideally, someone could click the pet’s individual page and there would be the Pinterest share button. But trying to use the permalink codes and the EE image tags did not work. Appreciate any help anyone can give here.

       
Genevieve's avatar
Genevieve
52 posts
14 years ago
Genevieve's avatar Genevieve

Hey, I don’t know if you already found a solution for this, but if not here’s how to get Pinterest to work with EE. Pinterest requires the permalinks and image src links used within its code to be url encoded. To do this with EE, you’d need to store the permalink and the image src in a PHP variable, and then use PHP’s urlencode().

So step by step: 1. Enable PHP on output on your template(s). 2. Store permalink and image src in PHP variables like this:

<?php $link = "{title_permalink='my_template/entry'}";
           $image = "{custom_image_field}";
?>
  1. Call those variables using urlencode() within your Pinterest code like this:
<a href="http://pinterest.com/pin/create/button/?url=<?php" class="pin-it-button">Pin It</a>
  1. Make sure the Pinterest javascript is in place just after your <body> tag:
<!-- Include ONCE for ALL Pin This buttons in the page -->
[removed]
(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;
        s.src = "http://assets.pinterest.com/js/pinit.js";
        var x = document.getElementsByTagName("script")[0];
        x[removed].insertBefore(s, x);
    }
    if (window.attachEvent)
        window.attachEvent("unload", async_load);
    else
        window.addEventListener("load", async_load, false);
})();
[removed]

Hope that helps!

       
Coastal Pet Rescue's avatar
Coastal Pet Rescue
53 posts
14 years ago
Coastal Pet Rescue's avatar Coastal Pet Rescue

Fantabulous! I will try that this weekend and get back to you!

       
Coastal Pet Rescue's avatar
Coastal Pet Rescue
53 posts
13 years ago
Coastal Pet Rescue's avatar Coastal Pet Rescue

No, didn’t work. But thanks for trying.

       
Coastal Pet Rescue's avatar
Coastal Pet Rescue
53 posts
13 years ago
Coastal Pet Rescue's avatar Coastal Pet Rescue

I’m using version 1.6.9

       
Coastal Pet Rescue's avatar
Coastal Pet Rescue
53 posts
13 years ago
Coastal Pet Rescue's avatar Coastal Pet Rescue

Ok, I got it to work… there was a ; between the media and = in the pin it button script, so removing that made it work. THANK YOU!!!!!

       
Coastal Pet Rescue's avatar
Coastal Pet Rescue
53 posts
13 years ago
Coastal Pet Rescue's avatar Coastal Pet Rescue

For anyone else who wants to add this, let me include the modifications I made to work on our site as I wanted to auto populate with the title of the page so someone didn’t have to type it in themselves (I’m a lazy pinner):

{exp:weblog:entries weblog="weblog_name" limit="1"}
<?php $linkPin = "{title_permalink='template/template_view/'}";
           $imagePin = "{image}";
           $descrPin = "Site Name {title}";           
?>  
{/exp:weblog:entries}

I put that above the exp tags that call the content to the page (since my header info is all in a separate template).

Then, for the button:

<a href="http://pinterest.com/pin/create/button/?url=<?php" class="pin-it-button">Pin It</a>[removed][removed]

*Where it says [removed][removed] should be the javascript tags you can copy from the Pinterest button page.

       
adamEEman's avatar
adamEEman
29 posts
13 years ago
adamEEman's avatar adamEEman

Did this work for you? We would like to see it in action if it did. Cheers.

       
filthproductions's avatar
filthproductions
3 posts
13 years ago
filthproductions's avatar filthproductions

The HJ Social Bookmarks plugin (ExpressionEngine 2.x) also supports the Pin It button.

       
adamEEman's avatar
adamEEman
29 posts
13 years ago
adamEEman's avatar adamEEman

Do you have any live examples where the social bookmarks plugin is in use? Thanks.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.