Back to vBulletin 4.x Template Modifications

Twitter - Tweet Button in SHOWTHREAD
Mod Version: 1.00, by BirdOPrey5

vB Version: 4.0.x Rating: (17 votes - 4.71 average) Installs: 146
Released: 14 Aug 2010 Last Update: 22 Aug 2010 Downloads: 307
Not Supported Template Edits Re-usable Code Translations External Content  

This mod is now outdated and as a result support for new installs will be limited, if any.

-July 7, 2011-

Please instead use my new mod which offers Twitter and many more share options for VB 4.x without template edits.

WARNING - It appears vBulletin has changed the location of the Facebook Like button in version 4.1.2. As a result it is likely the code changes below will be different in 4.1.2 and beyond, I will not be able to support installs beginning with version 4.1.2 since my license stops at 4.0.8.

Twitter released their new TWEET button.

Live Demo: http://www.juot.net/forums/index.php?t=41185
(Note my Live Board is VB 3.8, but I have tested this on 4.0.4 and 4.0.6)
(Update I have for the time being replaced the Tweet button with the http://www.addthis.com share button on my live forum. See the screen shots instead.)

I have tested this in latest versions of IE / Firefox / Chrome / Safari / Opera and it should work in all.

This will show you how to add this simple code to your SHOWTHREAD template above the page navigation bar, if visible.

If you DO NOT use the built-in Facebook Like button do the following:

Go to the Admin CP -> Styles & Templates -> Style Manager
Edit your SHOWTHREAD Template

Find: (The first instance of)
Code:
		<vb:if condition="$pagenav">
			{vb:raw pagenav}
		</vb:if>
Above this add:
Code:
<vb:if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
<div id="mytweetbutton" align="right" style="height:27px;">
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
</vb:if>
Change the X, Y, Z in the first line to the forumid's of any private forums you may have. If a guest can't view a forum there is no reason to link a tweet to it. You can add as many or as few forumid's here as you need, just separate each with a comma.
Valid Examples:
<vb:if condition="!in_array($GLOBALS[forumid], array(2, 5, 9))">
<vb:if condition="!in_array($GLOBALS[forumid], array(7))">
<vb:if condition="!in_array($GLOBALS[forumid], array(2, 3, 4, 5, 6, 7, 8))">
If none of your forums are private or you want to enable this in every forum you can remove the lines:
Code:
<vb:if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
and 
</vb:if>
Replace "YOUR_TWITTER_USERNAME" with your twitter username, it will be referenced in the tweet- but the tweet will not be from YOU, it will be from whoever hits the tweet button.

If you DO USE the built-in Facebook Like button do the following:

Find:
Code:
		{vb:raw fblikebutton}
Replace it with:
Code:
<div id="fb_likeframe" style="border: none; overflow: hidden; height: 27px; width: 95px; vertical-align: text-bottom; padding-top:1px;"><a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script></div>{vb:raw fblikebutton}
Replace "YOUR_TWITTER_USERNAME" with your twitter username, it will be referenced in the tweet- but the tweet will not be from YOU, it will be from whoever hits the tweet button.

The Tweet button will now show up next to the Facebook Like button in anytime the Facebook Like button is displayed in a thread.

----

When you hit the Tweet button you will be given a box to type a message if you're logged in. If you're not logged in you will be asked to login or join, all within the pop-up window.

This button code will count the number of tweets people have made using it. For other options including the button with no counter visit: https://twitter.com/goodies/tweetbutton

The screen shots show the Tweet button both with and without the page navigation bar, and with the Facebook Like button.

Please click Install if you use this.

Download the .txt file for a copy of the install instructions.

----

Known Issues- a few people have reported a 'slash' is missing in the URL submitted to Twitter on some boards. Other people have said URL's with non-english characters cause a URL error. The solution for both of these issues is in post #143

Spoiler (click to open)


OK... use this code... remember to replace the username with your own...

This should remove all the special characters from your URL so it should work with twitter... please let me know.

Code:
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME" data-url="{vb:raw vboptions.bburl}/showthread.php?t={vb:raw threadid}">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

Close
in this thread.

Also Twitter appears to be having widespread issues with the counter not working. Some sites it works, some it don't, sometimes it stops working, sometimes it starts working for no reason. If you find your count isn't working try the solution in post #147

Spoiler (click to open)


Yeah the count issue is a widely reported problem, some people are affected some aren't, there so far doesn't seem to be a rhyme or reason to it. One option is to disable the count completely by changing "horizontal" to "none" in the code.

One thing I would try first though is this code which tells it to specifically count the URL you're twittering:

Code:
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME" data-url="{vb:raw vboptions.bburl}/showthread.php?t={vb:raw threadid}" data-counturl="{vb:raw vboptions.bburl}/showthread.php?t={vb:raw threadid}">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

Close
. If that doesn't work than disable your counter completely if you want by changing the word "horizontal" to "none" in the twitter code.

Download

File Type: %1$s tweet_button_vb4.txt (3.3 KB, 315 downloads)

Screenshots

Click image for larger version
Name:	ss_tweet_vb4-1.jpg
Views:	2787
Size:	91.2 KB
ID:	120803   Click image for larger version
Name:	ss_tweet_vb4-2.jpg
Views:	1687
Size:	64.6 KB
ID:	120804   Click image for larger version
Name:	ss_tweet_vb4-3.jpg
Views:	1582
Size:	71.9 KB
ID:	121142  

Similar Mods

Show Thread Enhancements Twitter - Tweet Button in SHOWTHREAD vBulletin 3.8 Template Modifications
Mini Mods Facebook - Linkhay - Tweet - Yahoo Buzz Share with Above Button Cool vBulletin 4.x Template Modifications

vblts.ru supports vBulletin®, 2022-2024