Needs work
Project:
Pinterest
Component:
Miscellaneous
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Jan 2012 at 20:42 UTC
Updated:
13 Jan 2013 at 10:26 UTC
Is there a way to use your module so we can include a Pinterest button on every article and have it populate the Pinterest button with the proper canonical URL and primary image that is associated with every article?
Comments
Comment #1
mikefyfer commentedJust an fyi, something like this will do the trick. You'll put it in a block, or in a tpl, depending on what you're comfortable with or your use case.
There are a bunch of ways to get your $url (that variable by itself won't do anything). It'll be different depending on if you're on d6 or 7 - see Drupal API
But if you're looking to just pop a 'pin it' button on some page, something like this should work.
Comment #2
rhip commentedThank you mikefyfer.
I was wondering whether you would help me... I can't get this bit of the code to producing anything:
drupal_urlencode(_imagecache_strip_file_directory($node->field_image[0]['filepath'])The whole thing is fine except the name of the image is missing (it spits out this: www.mysite.com/sites/default/files/imagecache/recipe-620/recipeImages">Pin It )
I have the following code in a block on a page:
Comment #3
mikefyfer commentedRhiannonAmyBuck,
Sorry, my post in comment #2 was for Drupal 6.
If you're on D7, something like this should do the trick to get your image path. Where field_main_image is the main image for your node.
Hope it helps.
Comment #4
p55mac commentedI put the following code into my node--[content type].tpl.php using Drupal 7
Of course you may have a different name for the field image that you want to be selected and of course the description field etc too.
Hope this helps anyone.
Comment #5
sachbearbeiter commented#4 this solved me hours of research: file_create_url
thanks a lot ...
Comment #6
redhatmatt commentedHaving trouble with the Drupal 6 example, actually getting the pinterest page to actually submit the pin... it works all the way until I actually click "pin it" which then starts to work but ends up doing nothing and displays a blank image on the same page. If I do the urls manually from the pinterest wizard/goodies page everything works.
See: http://dev.pencils.com/forestchoice-hardcover-reporter-small-ruled
look down the page to find the pinterest button right after the facebook like button after the product description.
I get the full url:
and add the badge and all the basic stuff:
I'm breaking the code out so I can read it better, have been slow and methodical with a lot of troubleshooting. Please help ;)
Comment #7
redhatmatt commentedNever mind all that works just fine. I was working all this out for a long time (a few hours) and kept committing up to the server every so often with repeated failures. At some point I stopped committing just working locally. Finally when I posted the above code and question together to show an example it all worked when I tested a final time. Duh... the pinterest server couldn't communicate with my local when I finally did have the code right. Hopefully this helps someone out there... it's for Drupal 6.
Comment #8
redhatmatt commentedSpoke to soon. The images still don't show up as thumbs on http://pinterest.com/redhatmatt/products-i-love/
This would seem to be a pinterest problem but I know somehow I caused this originally, back to the drawing board. If anyone has any pointers on this part I'd love to hear em.
Comment #9
redhatmatt commentedEverything is fine now and I even added in the pre-filled description with the title. It just took pinterest awhile to either cache my images and spit them out or just catch up. Everything is now working swimmingly.
Comment #10
ayushjn commentedLooks like a Pin It button is what we are looking forward to ? . I will soon work on it.
Thanks all for the suggestion guys!!!
Comment #11
mealto commentedok, just found all the great response to my original question, thanks so much. When I opened the thread, there was no one else talking about Pinterest. I need some help here. I am guessing I have to populate some fields:
http://pinterest.com/pin/create/button/?url=http://www.domain.com/&descr...
How do I populate the article URL and imagecache URL? I have this code in a block.
The imagecache image is a cached image of a Primary Image that we have inserted for each article. How do I grab this URL as well as the URL of each article?
Any help would be appreciated!
Comment #12
mealto commentedBump. Anyone care to help out with some coding? Cannot get this to work :(