Comments

Oh yes, please!

+1

+1

uploaded it in the home page: http://servicelinks.altervista.org/

if someone would try it and give feedback is welcome...

I have used this and it works okay. The biggest issue with Pinterest is that there is no great way to get the image from your nodes. I have this on a site that always has an image on a separate field. So I was able to code some php code into the node template which gets the image. I can't see this being a workable solution but if it helps someone else here is the code that is working for us.

<a href="http://pinterest.com/pin/create/button/?url=<?php print urlencode($GLOBALS['base_url'].'/'.$node_url); ?>&media=<?php print urlencode($GLOBALS['base_url'] .'/'. $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>

-----------------

Which kind of goes hand in hand with another issue. Facebook never gets the right image to share and you can code it but it doesn't grab the image you tell it to use. So on the one hand you can code the images and maybe it works or the Facebook way which always has issues. Either way is not great.

Just tried it out too using my wife's Pinterest account and it doesn't work on your blog because no image is associated with the "Pin It" button. As a result nothing is posted. It pops up and lets you login just fine - goes all the way through, but without an image it doesn't actually do anything when you submit the pin.

BTW, I'll be around for another 4-5 hours so can test iterations if you'd like. I'll keep this thread handy. I'd much prefer using Service Links than hard-coding this.

I'm looking at the code for the WordPress Pinterest Plugin and noticed that in js/pinterest-pin-it-button.js it calls https://assets.pinterest.com/js/pinmarklet.js instead of http://assets.pinterest.com/js/pinit.js (what you're calling, and indeed what the http://pinterest.com/about/goodies/ generator calls).

Haven't looked into the pinmarklet.js code in depth, but an initial perusal makes me wonder if it scans the page for images vs. pinit.js expects an image URL to be given to it. Thoughts?

Looks like I was on the right track - these blogs confirm:
http://www.squarespaceplugins.com/add-pinterest-pin-it-share-button-in-s...
http://help.squarespace.com/customer/portal/articles/376251-adding-pinte...

Only down-side of using the pinmarklet.js code is it sounds like you lose the pin count bubble (bottom comments http://developers.squarespace.com/design-coding/post/1729891).

Hmmm...potential option to use pinit.js and grab first node image-field: http://stackoverflow.com/questions/6656595/how-to-get-the-first-image-fi...

Any chance you could include a patch/code for Pinterest so I can start playing around with it?

Nevermind, just found out we're supposed to use Gigya. Plus going to put Pinterest underneath each image on the site instead of on the page, so that will avoid the problem entirely.

StatusFileSize
new10.99 KB

this is the widget module i am working on but for 7.x

Version:6.x-2.1» 7.x-2.x-dev
Status:Active» Needs review
StatusFileSize
new6.26 KB
new3.89 KB

@TheCrow looks ok, here.

The patch for TheCrow's work. We can backport this to 6.x once reviewed.

finally i got my pinterest account! seems there is a mistake with the description field, the right tag is <raw-encoded-teaser>, my mistake,
Concerning the picture i could implement a way to use a token to fill the media parameter...

StatusFileSize
new3.46 KB

Here a patch to try

[Edit]
Add also the javascript included in the first package under the "js" folder

Looking forward for a D6 backport. Let us know if/when help is needed.

The latest patch for both versions.

I am getting errors on D6 patch. Do I need to put a token in the Media parameter? How do I choose?

warning: Illegal offset type in /home/demo/public_html/sites/all/modules/contrib/token/token.module on line 332.
warning: Illegal offset type in /home/demo/public_html/sites/all/modules/contrib/token/token.module on line 337.
warning: Illegal offset type in /home/demo/public_html/sites/all/modules/contrib/token/token.module on line 346.
warning: array_merge() [function.array-merge]: Argument #2 is not an array in /home/demo/public_html/sites/all/modules/contrib/token/token.module on line 346.
warning: array_keys() [function.array-keys]: The first argument should be an array in /home/demo/public_html/sites/all/modules/contrib/token/token.module on line 349.
warning: array_values() [function.array-values]: The argument should be an array in /home/demo/public_html/sites/all/modules/contrib/token/token.module on line 350.
warning: Invalid argument supplied for foreach() in /home/demo/public_html/sites/all/modules/contrib/token/token.module on line 413.

StatusFileSize
new5.06 KB

There is a mistake in the use of token_replace function for 6.x:

replace this:

<?php
$settings
['subst']['pinterest-media'] = rawurlencode(token_replace($media_token, array('node' => $node)));
?>

with:

<?php
$settings
['subst']['pinterest-media'] = rawurlencode(token_replace($media_token, 'node', $node));
?>

reworked patch attached!

Concerning the token to add, maybe this module could help you: http://drupal.org/project/token_field
otherwise just implement your custom token following the token documentation page

Great work but the 20# patch need some implementation (6.x.)

The button and the link are ok in my case, but when i click the button, the pupup won't post the pin ... maybe becouse in the code of the button there's not image or description?

By the way the url link seems ok but don't figure why the pinterest popup window don't let me complete the pinit process.

#21 tested and works great 4 me I putted the imagecache path in the media field builded with the Custom Token Module.

Thanks!

@fabioloool Thank you to remember us this: http://drupal.org/project/token_custom, i was aware of some helpful module to achieve our goal but i forgot their links!

StatusFileSize
new5.9 KB

Custom token is wonderfull.
I just added the description field integrated with tokens too...
I'm new in pathc system.. hope it's ok!

Status:Needs review» Needs work

@fabioloool, your patch at #24 fails. I didn't manage to understand why.

Comments on the patch at #20: There is no icon in the admin list and the widget is not shown, also for a lack of icon.
The admin icon can be arranged with adding an icon to the images folder. However, it seems as if the widget should come from Pinterest itself. Does it work for you?

icon at #14 or #13, patch at #18 for D7 and #20 for D6, a working example is in the home page.
#24 have to be reworked a little.

#24 works for me ... is for drupal 6 .. you can see it here in action http://adoroletuefoto.it/contest/ritratto-di-persona-portrait-person/ice...

#20 leaves me without an image to pin. I used the filepath token. I also noticed the filepath used is for the original image, not the imagecache version.

#24 won't apply. I get error:

patch: **** malformed patch at line 62: +    '#description' => t('Fill the description parameter with a token which will be evaluated by <a href=@url>Token</a> module.', array('@url' => 'http://www.drupal.org/project/token')),

#24 just add a configurable description tag with token... i reworked it a little and attached here.

concerning the image, check in the source page the link generated for the pinterest service it should have the parameter &ampmedia=full-path-to-your-image, if is not like that print here the result.

I didn't tried filefield token but fabioloool used http://drupal.org/project/token_custom successfull, and me i created a custom token just as example here: http://servicelinks.altervista.org/.

#31 works. I just had to add site-url and file-path tokens. Thanks.

>>>Which kind of goes hand in hand with another issue. Facebook never gets the right image to share and you can code it but it doesn't grab the image you tell it to use. So on the one hand you can code the images and maybe it works or the Facebook way which always has issues. Either way is not great.<<<<

Are you using the Open Graph Meta Tags module?

You can specify which image you want FB to use.

http://drupal.org/project/opengraph_meta

@mattwmc - I am not using the open graph meta tags module. It sure looks promising.

Here is a code that allows the user to choose the image.

I hardcoded it to my pages through the page.tpl.

Is there a way to incorporate it here?

1. In the HTML at the end of every blog post (right in the body of the post in HTML View)

2. Inside the loop of your post template file (typically single.php, single-post.php, single-photo.php, or something similar)

3. Using an action hook — depending on how much of a geek you are, this may be a bit much, but many WordPress themes come with features that make the addition of hooks a simple cut-and-paste.

<div><a href="javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)})());"><img class="aligncenter" src="http://www.clickinmoms.com/cmprodaily/wp-content/uploads/2011/09/pinit.jpg" alt="Pin It" /></a></div>

via: http://www.clickinmoms.com/blog/add-a-pinterest-pin-it-button-to-all-of-...

Version:7.x-2.x-dev» master
Status:Needs work» Fixed

Codes pushed in the repo.

@mattwmc i suggest to play with tokens instead.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

Using the patch from #31 with service_links 7.x-2.x-dev, has the pinterest button disappeared for anyone else?

I previously used the patch from #14 and it worked fine except that the descriptions were broken.

If I turn off Javascript I see the pinterest link in the source:

<a target="_blank" rel="nofollow" title="Pin It" class="pin-it-button service-links-pinterest-button" href="http://pinterest.com/pin/create/button/?url=http%3A//sample.wild.com/shop/stitch-time&amp;description=&amp;media=%3Cpinterest-media%3E"><span class="element-invisible">Pinterest</span></a>

Once I enable Javascript, the link is removed (I believe when pinit.js is loaded). Also, even though I have added tokens for Description and Media, nothing is being appended to the URL. I see references to the Custom Token module, is this required?

any updates, is this committed to dev?

#36 is the answer for both

Thanks, shows nicely!

I just installed latest dev release but pin it button doesn't shows in my panel pages.
Every other service is working fine, and pinit.js gets loaded too. Just the pinit html part doesn't render at all.
Any clues?

It works for me in panels...

I´m obtaining this Error message when trying to use service links as a field in Views and when I include Pinterest:

EntityMalformedException: Missing bundle property on entity of type node. in entity_extract_ids() (line 7501 of /path/to/drupal/includes/common.inc).

There is no rendered content in the whole page when the error occurs. For avoiding this I just disable the Pinterest service (or avoid the use of tokens), and that made me think firstly that the problem was related to Pinterest (and more specifically, probably, with the token implementation, but I can´t provide further details on that). The error is not popping up in node teasers or full view, just only in Views fields.

I´m using:

drupal 7.14
service links 7.x-2.x-dev (latest version, with no patches related to Pinterest)
views 7.x-3.3

Quick fix for error from #44:
Simply add code:

<?php
$node
= node_load($node->nid);
?>

at the beginning of function ws_pinterest_button_tags() in services/widget_services.module

Trying hard to get the Pinterest button on my D6 product and blog nodes. Post #35 works, but I would rather use the .dev version with the token_custom fix instead. I know nothing about php, so I don't have the first clue about creating a custom token. Would love it if you shared your custom token code so us noobs can use it as a template. I've got the token_custom mod downloaded.

Thanks!

There is a module for pinterest http://drupal.org/project/pinit

How can we use pintrest username to login to my website???Pls help me!!!
Just like Fb connect or twitter oauth!!!

@LEKSHMY you might try askng your question of the pinit module, service links is not the correct place to ask this question since it does not provide any kind of external authentication.

You'd also be better off opening a new issue asking your question specifically - not adding an unrelated comment on a completely different issue. If you open a new issue and ask a question in the wrong place then someone else can help you out and re-assign the issue to the correct module for you.

@TheCrow thank you so much for all your work on this module :)

The patch in #31 has whitespace errors for me (line 130) and appears not to be formed correctly (missing git's a/b directory compare stuffs.) Also, after I got the patch correctly applied, it looks like the option for enabling the pinterest widget is missing (although the pinterest link option is there, as well as the new settings form options for the pinterest widget).

I'm going to try to install the dev branch and see if things are any better over there.

*UPDATE* The dev branch works great, with the one exception that using existing tokens for image fields seem to make the Pinterest button not show up anymore. I ended up writing my own little token module that returns the URL of first image on the node, which the Pinterest widget seems to like. if anyone would like to use it you can grab it from github.

Sweet! @jenlamption, I'm trying to add pinterest as a general service, but a manner to call the first image is what I'm lacking. Is there a way in which I can use your token? For more information please have a look at the http://drupal.org/node/1664076

Appreciated. :D

For Drupal 7, I used the Custom Token Module and the following php code to define the token. This gives you a token that returns the url of the first image in a field, with the image style setting applied (main_listing_image, in this case).

<?php
 
if (arg(0) == 'node' && is_numeric(arg(1))) {
   
$node = node_load(arg(1));
    if (
$node && $node->type == "feature_listing") {
     
$values = $node->field_photos['und'];
      if (
$values != FALSE) {
       
$val = $values[0]['uri'];
       
$val = image_style_url("main_listing_image", $val);
       return
$val;
      }
}
}
?>

Hope that helps!

This is a start, but I keep getting a broken image when I try this code. Am I supposed to change out some of the variables in the php code above to get to work? Does this only work for one node type and one field type?

Status:Closed (fixed)» Needs review

Are you sure this is fixed? I installed Service links and activated: General services + widget services and 'Pinterest Widget' does not appear at all while other services yes.

Thanks @jglynn for the help. I was able to create a custom token for the image field, but I have no idea to to implement its use. Once I have the token what do I do with it? Adding it to my widget just outputs the token name, not an actual image url leaving me with an "image not found". :(

Version:master» 7.x-2.x-dev
Status:Needs review» Closed (fixed)

Please use the -dev version of the module to have "Pinterest" widget available.

Is there a way to convert the pinterest image token (or any token) to a "tag" like so it can be used in a general service?

May an option to create custom tags?

The reason I'm specifically interested in the general service as opposed to the widget is the widget does not allow one to override the icon. :( I already have a working "general" service, without an image, for Pinterest. http://drupal.org/node/1664076

the 'preset' field and related function is what you need.

I think one of the issues people are having (myself included) is what the media parameter field is and how to use it. I understand tokens, but I am not sure how to integrate them in this case, since my images are used in a variety of contexts with different paths to the image. Here is a link to my page on my dev site and you can see the image comes up broken:

http://dev.bkwinery.com/fall-2012-harvest-update/2411

Any help would be greatly appreciated.

Also does this only pick one image or does it work when there are multiple images on the page?

Status:Closed (fixed)» Active

maybe some news about multiple images: http://business.pinterest.com/widget-builder/#do_pin_it_button
the button look accept a new parameter... any image... have to see it better.

waltercat, I visited your site via the link provided and it seems you now have a working Pintrest button that appears to be separate from the service links Pintrest button that still doesn't work. If you can please explain how you did this I would be very grateful.

damonbha, I broke down just used the pinterest code on their site: http://business.pinterest.com/widget-builder/#do_pin_it_button

It isn't what I really want to do as it only works for about 50% of my image cases. What I really want to do is figure out a way to pin my images from a lightbox window. But there seems to be very little interest on making pinterest work with drupal, I've spent a lot of time searching around and haven't found much. I would personally love something that works like this where you simply hover over the image and you can pin it: http://www.stylemepretty.com/2013/04/05/costa-rica-wedding-from-a-brit-a...

From a marketing and SEO standpoint, being able to allow people to simply pin images is game changing for sites like mine.

Waltercat, it seems like you could do what you want to do by simply creating a field-name-[field_name].tpl.php file in your theme. Then you could use the $items variable to pull the uri for the image. Use some simple hover css and there ya go... Here's a quick example of what I think might work, though I haven't tried it myself.

<div class="<?php print $classes; ?>"<?php print $attributes; ?>>
<a href="//pinterest.com/pin/create/button/?url=<?php print 'http://example.com/node/'.$node->nid; ?>&media=<?php print 'http://example.com/'. str_replace('public://', 'sites/default/files/', $items->field_image['und'][0]['uri']); ?>&description=<?php print $node->title; ?>" data-pin-do="buttonPin" data-pin-config="above"><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png"></a>
  <?php if (!$label_hidden): ?>
    <div class="field-label"<?php print $title_attributes; ?>><?php print $label ?>:&nbsp;</div>
  <?php endif; ?>
  <div class="field-items"<?php print $content_attributes; ?>>
    <?php foreach ($items as $delta => $item): ?>
      <div class="field-item <?php print $delta % 2 ? 'odd' : 'even'; ?>"<?php print $item_attributes[$delta]; ?>><?php print render($item); ?></div>
    <?php endforeach; ?>
  </div>
</div>

I'm not sure if the $node variable is available in field.tpl.php files, so if it's not you would have to do something else to get the page url to work. Use this as a reference and let me know if you get it working (http://api.drupal.org/api/drupal/modules%21field%21theme%21field.tpl.php/7). I may do this on one of my sites one of these days, but I hadn't even thought of it until you posted here. Might be a good idea to make this a separate issue as a feature request with a UI admin checkbox to enable a hover pin it image over any images.

@32 - Anychance you could document what you put in these fields as 1/2 day of frustration hasn't gotten me very far!?

Thanks in advance

The pinterest button does not seem to be working in general yet without extra code hacked in, correct? Working on a D6 version, or perhaps the backports are not added yet?

Disregard, I got it, it was a simple soln. thank you!