Dave Tips

Tips for computers and the internet. How to, tips, tricks and resources for computers and the web.

Friday, May 30, 2008

Blogger 'Share on Facebook' Code

If you have a blogger blog, and want your visitors to easily share your posts with their facebook friends, you can make blogger automatically place a 'share on facebook' link at the end of each post. Add this code after the body of the post:

for layouts (in the "Edit HTML" pane with the "Expand Widget Templates" check box checked):

<b:if cond='data:post.url'>
<br/>share <a expr:href='data:post.url' title='permanent link'>this</a>: <a expr:href='&quot;http://www.facebook.com/share.php?u=&quot; + data:post.url'>facebook</a>
</b:if>


for classic templates:

share <a href="<$BlogItemPermalinkURL$>" title="permanent link">this</a>: <a href="http://www.facebook.com/share.php?u=<$BlogItemPermalinkURL$>">facebook</a>

and you'll also have a permalink before the 'share on facebook' link.

You can also add a link for sharing and saving for other social networking and social bookmarking sites too. If you'd like the code for that, please leave a comment.

Labels: , ,

4 Comments:

Blogger MG said...

Hi there,
Do you know of anyway to display these links as the favicons for the associated webpages instead of the "share on facebook" text?

June 11, 2008 10:34 PM  
Blogger David August said...

Displaying favicons can't easily be done inline on a web-page; the favicon file format doesn't usually get rendered on a page the way a gif, jpg or png file does. What you can do is replace the "facebook" text that's the link text in the code above with an img tag using any image you want. You have to first download the image and host it somewhere online yourself, like photobucket.com (unless you get too much traffic for photobucket to work). Your best bet is to host the image in your own web hosting space, and than link to it from there.

June 15, 2008 2:54 PM  
Blogger D. James McSaddle said...

I'd like that cote. . . .for the expanded tool bar.

June 29, 2008 6:57 PM  
Blogger Callsign Echo said...

Your code for facebook worked perfectly, thanks. I'd love to see the same thing for digg, stumble upon, etc...

July 15, 2008 10:52 AM  

Post a Comment

Links to this post:

Create a Link

<< Home