tweet button & twitter badge

Topics: Controls, Themes
Jun 19, 2011 at 4:04 AM

Hey guys!

Firstly I'd like to congratulate you on BlogEngine, quite amazing indeed! With no experience whatsoever we have managed to get our website's design sorted out in less than a day, so we can finally start adding up content!

Two questions related to twitter:

1) If you visit our site you will see that I created a widget and added inside the default Twitter badge code. While this works fine, some underscores are rendered after the description (notice "dotNETportal______________") while the underscores are not supposed to be there. Could you give me some hints on where to look about this? Something to do with the theme perhaps?

2) I have added a 'Tweet' button in PostView.ascx. The code is below:

<a href="" class="twitter-share-button" data-text=<%= Post.Title %> data-count="horizontal" data-url=<%= Post.AbsoluteLink %> data-via="dotNETportal">Tweet</a><script type="text/javascript" src=""></script>

However, if you try this button on the posts of my site, you will see that when trying to Tweet, only the first word of the title appears in Twitter (while I thought that Post.Title gets the whole title). Can anyone shed some light into this?

Thanks for your help in advance.



Jun 19, 2011 at 12:44 PM

#2: You have to UrlEncode the title when sending it in URL to twitter.

See this tweet button that I created some time back.

Jun 19, 2011 at 1:59 PM

Hey bitnbytes,

thanks for the hint. I have modified the command like this:

<a href="" class="twitter-share-button" data-text=<%= Server.UrlEncode(Post.Title) %> data-count="horizontal" data-url=<%= Post.AbsoluteLink %> data-via="dotNETportal">Tweet</a><script type="text/javascript" src="">

Now it displays the whole title but words are separated with a + sign (for example "welcome to my website" becomes "welcome+to+my+website"). How can I tweak this to replace the + with spaces?

Jun 19, 2011 at 9:16 PM

I just looked at implementation on my own blog. You really do not have to url encode the title. One thing that you may be missing is that string in data-text needs to be inclosed in quotes. For example notice the tag from my site.

<a href="" class="twitter-share-button" data-url="" data-text="Cool Windows 7 Tools - Magnifier to enlarge view in windows" data-count="vertical">Tweet</a>

Check it out my blog if you want more examples.