
In case you are unfamiliar, Pinterest is an online pinboard that allows users to share images they find over the web -by “pinning” them on their boards. The pinned image is linked to the original webpage or blog post location, giving users the chance to visit the source directly.
A Pin It button is what
Like button is to Facebook or
Tweet button is to Twitter, as it allows users to share your posts without having to leave your blog. It also displays how many times a blog post has been shared.
Unlike a typical Pin It button, our version doesn’t pre-select an image from a post; it displays all available images and lets your readers choose the image they like to pin.
Now let’s proceed with the tutorial:
- Go to Design > Edit HTML (New interface: Template > Edit HTML).
- Back up your template.
- Check the Expand Widget Templates checkbox on top right of the HTML window.
- Look for the following data tag in your HTML. This is the tag for the post content:
Normally there are two instances of the tag present in your template. Locate the the first (from top) one.
- Paste the following code immediately below (after) it:
02 | < b:if cond = 'data:blog.pageType == "item"' > |
03 | < div id = 'pin-wrapper' style = 'margin:5px 10px 5px 0; text-align: left;' > |
04 | < a class = 'pin-it-button' count-layout = 'horizontal' expr:href = '"http://pinterest.com/pin/create/button/?url=" + data:post.url' >Pin It</ a > |
05 | < a href = 'javascript:void(run_pinmarklet())' style = 'margin-left:-93px; width:43px; height:20px; display:inline-block;' /> |
07 | < script src = 'http://assets.pinterest.com/js/pinit.js' type = 'text/javascript' /> |
08 | < script type = 'text/javascript' > |
09 | function run_pinmarklet() { |
10 | var e=document.createElement('script'); |
11 | e.setAttribute('type','text/javascript'); |
12 | e.setAttribute('charset','UTF-8'); |
13 | e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r=' + Math.random()*99999999); |
14 | document.body.appendChild(e); |
This code is made up of a combination of two different codes -Pinterest Pin It button and Pinterest bookmarklet. Why a combination? Because the Pin It button code (that’s supposed to do the job) provided by Pinterest simply doesn’t work, at least not on Blogger, for now.
- Button configuration
You can customize the layout of Pin It button & counter by changing the value of count-layout
attribute in line 4. Refer to the table below for the available types and their settings.
Button type
|
count-layout value
|
margin-left (in line 5) value
|
 |
vertical
|
-46px
|
 |
horizontal
|
-93px
|
 |
none
|
-46px
|
- Button placement
The steps above position the button on bottom left of each post. To change the button position, do the following:
- Position it on top of post
Place the button code before <data:post.body/>
, instead of after.
- Button alignment
Change the value of text-align
property in line 3:
Align right: set it to right;
Align center: set it to center;
- Click Save.
- View your blog. The button should appear on post pages.
Update:
Adding Pin It button as a widget
To put Pin It button outside post area e.g. in sidebar or footer, paste the following code into a HTML/Javascript gadget. The button will appear on all pages (not just post pages), but it comes without the counter.
01 | < a href = 'javascript:void(run_pinmarklet1())' >< img src = "https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5uRsuvdWG_murQH7grfZCeiuIvaYDsgWmLe-ROIpc8c7IfhJZ-Jfg-mk3DYlW1tNWBWfvdBJwFJWx__sgTvg2yTJpc9t0fLwiWpNUxFhpuK060vPHyKHSf4yjLpvprfI27Y7WRJuDBBZo/s1600/pinmask2.png" style = 'margin:0; padding:0; border:none;' /></ a > |
02 | < script type = 'text/javascript' > |
03 | function run_pinmarklet1() { |
04 | var e=document.createElement('script'); |
05 | e.setAttribute('type','text/javascript'); |
06 | e.setAttribute('charset','UTF-8'); |
07 | e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999); |
08 | document.body.appendChild(e); |
Enjoy!
No comments:
Post a Comment