Would love to add the pin it button to services. It's been awesome for +1, Like, Tweet and InShare and would love to add it to the mix. Information on the pinterest button can be found here: https://pinterest.com/about/goodies/

Comments

kylebrowning’s picture

Status: Active » Closed (fixed)

This can be done in a contrib module.

Until pinterest is supported in core, this wont be supported in services.

mikefyfer’s picture

Just an fyi, something like this will do the trick

<a href="http://pinterest.com/pin/create/button/?url=<?php print $url; ?>&media=<?php print file_create_url(file_directory_path() .'/imagecache/whatever-size/'. drupal_urlencode(_imagecache_strip_file_directory($node->field_image[0]['filepath'])));
?>" class="pin-it-button" count-layout="horizontal">Pin It</a>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>

There are a bunch of ways to get your $url, but if you're looking to just pop a 'pin it' button in, something like this will work.

haysuess’s picture

I am trying to do this in views and am close but need a couple things. I am displaying the Pin It button on each node using views.

Here is my code

<a href="http://pinterest.com/pin/create/button/?url=<?php
$targetPath = "node/";
$targetPath .= $data->nid;
$targetPath = 'http://'.$_SERVER['HTTP_HOST'].base_path().drupal_get_path_alias($targetPath, $path_language = '');
print $targetPath; ?>&media=IMAGEPATH&description=NODETITLE" class="pin-it-button" count-layout="horizontal">Pin It</a>

<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>

I got it to work like this for just the URL, not the image or description.

The image path code you provided does not work in Views, I'd also like to include the node title as the description.

How can I do this? Any help would be greatly appreciated. :)

mikefyfer’s picture

That code was for d6. See my comment over here http://drupal.org/node/1400142#comment-5736766 and that might help with getting the image in d7.

windm’s picture

Hi there,

I´m trying to use that code snippet in d6, but the media=... does not contain the entire filepath...

I removed the .'/imagecache/whatever-size/' due to the fact, that my "original" image is at /sites/default/files/my_imagefolder/imagename.jpg

I of course replaced the "field_image" with the right "field_myimagefieldname" but the generated link ends at ...sites/default/files - means the filepath is not added to the directory above...

Can this be related to using this piece of code in a view embedded in a panel? Do I need to change something then?

windm’s picture

Hi again,

just to let you know - it works with views, although I put the Pin it button in a view pane that is placed in a panel (that replaces the node itself)

First I tried to work with "rewrite the output of the field"... to get the backlink, the image-URL and the node-title as a description into the pinterest link, but I haven´t made it to get the mixture of HTML and drupal Tokens "urlencoded". The requests worked somehow, but they contained some blanks and special characters depending on the node-title...

Now I choosed a solution with a custom php field loading the node content first. With that node_load I can use the required variables ($node->path, field_image[0]['filepath'], title) within the rawurlencode() and the generated Pin It link looks fine (and encoded).

raulmuroc’s picture

In theory this module lets you this functionality: Service Links

But I do not find the Pinterest Widget nowhere :S

raulmuroc’s picture

Status: Closed (fixed) » Active

This is not fixed, I do not know why it has been set as closed(fixed), at least "posponed".

kylebrowning’s picture

Status: Active » Closed (won't fix)

This is wont fix because Services maintainers will not be adding this to Services core as Drupal Core does not support it.

Services aims to maintain features that Drupal core does, nothing more, nothing less.

Look at what I said, in #1.