There are a few modules that will accomplish this but sometimes I want to have more control on placement in my node template files.
The Pinterest Pin It button requires three parameters:
- URL of the page to pin (required, start with http)
- URL of the image to pin (required, start with http)
- Description of the page to be pinned
We can get these three parameters in the node template files with the following PHP statements.
- print $node_url;
- print image_style_url('image_style',$node->field_image_name['und'][0]['uri']);
- print $title;
<a href="http://pinterest.com/pin/create/button/?url=<?php print $node_url;?>&media=<?php printimage_style_url('image_style',$node->field_image_name['und'][0]['uri']); ?>&description=<?php print $title; ?>" class="pin-it-button" count-layout="horizontal">Pin It</a><script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>
If you need more than one Pinterest Pin It button on a page you can simply put the script statement at the bottom of the page just before the closing body tag.
No comments:
Post a Comment