Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x Template Modifications
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Twitter - Tweet Button in SHOWTHREAD Details »»
Twitter - Tweet Button in SHOWTHREAD
Version: 1.00, by BirdOPrey5 (Senior Member) BirdOPrey5 is offline
Developer Last Online: Aug 2023 Show Printable Version Email this Page

Category: Show Thread Enhancements - Version: 4.0.x Rating:
Released: 08-13-2010 Last Update: 08-20-2010 Installs: 146
Template Edits
Re-useable Code Translations  
No support by the author.

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/showthread.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 Add This 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: http://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. :up:

----

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 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. 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 Now

File Type: txt tweet_button_vb4.txt (3.3 KB, 313 views)

Screenshots

File Type: jpg ss_tweet_vb4-1.jpg (91.2 KB, 0 views)
File Type: jpg ss_tweet_vb4-2.jpg (64.6 KB, 0 views)
File Type: jpg ss_tweet_vb4-3.jpg (71.9 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #52  
Old 08-23-2010, 08:35 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If you go to your template editor and edit your showthread template...

Then copy and paste the "top" part of the file here I can look through it and suggest a location you could put the code.

If you could copy and paste everything in showthread above:
Code:
<li><a href="poll.php?{vb:raw session.sessionurl}do=newpoll&amp;t={vb:raw threadid}">{vb:rawphrase add_a_poll_to_this_thread}&hellip;</a></li>
					</vb:if>
				</ul>
			</li>
Reply With Quote
  #53  
Old 08-24-2010, 10:16 AM
Alucard^'s Avatar
Alucard^ Alucard^ is offline
 
Join Date: Feb 2008
Location: Argentina
Posts: 124
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

If i am not wrong this is the code that you want:

PHP Code:
{vb:stylevar htmldoctype}
<
html xmlns="http://www.w3.org/1999/xhtml"<vb:if condition="$vboptions['enablefacebookconnect']"xmlns:fb="http://www.facebook.com/2008/fbml"</vb:if> dir="{vb:stylevar textdirection}" lang="{vb:stylevar languagecode}" id="vbulletin_html">
<
head>
    {
vb:raw headinclude}
    <
vb:if condition="$threadinfo['keywords']"><meta name="keywords" content="{vb:raw threadinfo.keywords}" /></vb:if>
    <
meta name="description" content="{vb:raw thread.meta_description}" />

    <
title>{vb:raw thread.prefix_plain_html} {vb:raw thread.title}</title>
    <
link rel="canonical" href="{vb:raw thread_url}" />
    <
vb:if condition="$show['reputation']">
    <
script type="text/javascript" src="clientscript/vbulletin-ajax-reputation.js?v={vb:raw vboptions.simpleversion}"></script>
    </
vb:if>
    <
script type="text/javascript" src="clientscript/vbulletin_textedit.js?v={vb:raw vboptions.simpleversion}"></script>
    <
script type="text/javascript" src="clientscript/vbulletin_post_loader.js?v={vb:raw vboptions.simpleversion}"></script>
    <
vb:if condition="$show['threadrating']">
    <
script type="text/javascript" src="clientscript/vbulletin_ajax_threadrate.js?v={vb:raw vboptions.simpleversion}"></script>
    </
vb:if>
    <
vb:if condition="$show['multiquote_global']">
    <
script type="text/javascript" src="clientscript/vbulletin_multi_quote.js?v={vb:raw vboptions.simpleversion}"></script>
    </
vb:if>
    <
vb:if condition="$show['quickedit']">
    <
script type="text/javascript" src="clientscript/vbulletin-editor.js?v={vb:raw vboptions.simpleversion}"></script>
    <
script type="text/javascript" src="clientscript/vbulletin_quick_edit.js?v={vb:raw vboptions.simpleversion}"></script>
    </
vb:if>
    <
vb:if condition="$show['quickreply']">
    <
script type="text/javascript" src="clientscript/vbulletin_quick_reply.js?v={vb:raw vboptions.simpleversion}"></script>
    </
vb:if>
    <
vb:if condition="$show['manage_tag']">
    <
script type="text/javascript" src="clientscript/vbulletin_ajax_taglist.js?v={vb:raw vboptions.simpleversion}"></script>
    <
script type="text/javascript" src="clientscript/vbulletin_ajax_suggest.js?v={vb:raw vboptions.simpleversion}"></script>
    </
vb:if>
    <
vb:if condition="$show['lightbox']">
        <
script type="text/javascript" src="clientscript/vbulletin_lightbox.js?v={vb:raw vboptions.simpleversion}"></script>
    </
vb:if>

    <
vb:if condition="$vboptions['storecssasfile']">
        {
vb:cssfile showthread-rollup.css}
    <
vb:else />
        {
vb:cssfile postlist.css,showthread.css,postbit.css,attachment.css,poll.css,lightbox.css}
    </
vb:if>

{
vb:raw headinclude_bottom}
</
head>

<
body<vb:if condition="$onload"onload="{vb:raw onload}"</vb:if>>

{
vb:raw header}
{
vb:raw navbar}
{
vb:raw template_hook.showthread_above_posts}
{
vb:raw poll}

    <
div id="above_postlist" class="above_postlist">
        <
vb:if condition="$show['largereplybutton']">
            <
a href="newreply.php?{vb:raw session.sessionurl}p={vb:raw LASTPOSTID}&amp;noquote=1" 
class="newcontent_textcontrol" id="newreplylink_top"><vb:if condition="$show['closethread']"><span>+</span> {vb:rawphrase reply_to_thread}<vb:else />{vb:rawphrase closed_thread}</vb:if></a>
            <
img style="display:none" id="progress_newreplylink_top" src="{vb:stylevar imgdir_misc}/progress.gif"  alt="" />
        </
vb:if>

        <
div id="pagination_top" class="pagination_top">

<
vb:if condition="!in_array($GLOBALS[forumid], array(191, 192, 217, 114, 216))">
<
div align="right" style="height:27px;">
<
a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Compartir</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript">
</
script>
<
a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="nvnetgroup">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</
div>
</
vb:if>


        <
vb:if condition="$pagenav">
            {
vb:raw pagenav}
        </
vb:if>
            <
div id="postpagestats_above" class="postpagestats">
                {
vb:rawphrase showing_results_x_to_y_of_z, {vb:raw pagenumbers.first}, {vb:raw pagenumbers.last}, {vb:raw totalposts}}
            </
div>
        </
div>
    </
div>
<
div id="pagetitle" class="pagetitle">
    <
h1>
        {
vb:rawphrase thread}: <span class="threadtitle"><a href="{vb:raw thread_url}" title="{vb:rawphrase reload_this_page}">{vb:raw threadinfo.title}</a></span>
        <
vb:if condition="$show['fb_likebutton']">
            {
vb:raw fblikebutton}
        </
vb:if>
    </
h1>
</
div>
    <
div id="thread_controls" class="thread_controls">
        <
div>

        <
ul id="postlist_popups" class="postlist_popups popupgroup">

            <
vb:if condition="$show['firstunreadlink']">
            <
li class="popupmenu"><h6><class="firstunread" href="{vb:raw firstunread}">{vb:rawphrase view_first_unread} </a></h6></li>
            </
vb:if>
            <
li class="popupmenu" id="threadtools">
                <
h6><class="popupctrl" href="javascript://">{vb:rawphrase thread_tools}</a></h6>
                <
ul class="popupbody popuphover">
                    <
li><a href="printthread.php?{vb:raw session.sessionurl}t={vb:raw threadid}<vb:if condition="$perpage">&amp;pp={vb:raw perpage}</vb:if><vb:if condition="$pagenumber">&amp;page={vb:raw pagenumber}</vb:if>" accesskey="3" 
                        
rel="nofollow">{vb:rawphrase show_printable_version}</a></li>
                    <
li><a href="sendmessage.php?{vb:raw session.sessionurl}do=sendtofriend&amp;t={vb:raw threadid}"
                        
rel="nofollow">{vb:rawphrase email_this_page}&hellip;</a></li>
                    <
li>
                        <
vb:if condition="$show['subscribed']">
                            <
a href="subscription.php?{vb:raw session.sessionurl}do=removesubscription&amp;t={vb:raw threadid}" 
                                
rel="nofollow">{vb:rawphrase unsubscribe_from_this_thread}</a>
                        <
vb:else />
                            <
a href="subscription.php?{vb:raw session.sessionurl}do=addsubscription&amp;t={vb:raw threadid}" 
                                
rel="nofollow">{vb:rawphrase subscribe_to_this_thread}&hellip;</a>
                        </
vb:if>                    
                    </
li>
                    <
vb:if condition="$show['addpoll']"
Thanks.
Reply With Quote
  #54  
Old 08-24-2010, 01:14 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I would have preferred the code before you inserted the Twitter code but let's try this:

Find:
Code:
<vb:if condition="!in_array($GLOBALS[forumid], array(191, 192, 217, 114, 216))">
<div align="right" style="height:27px;">
<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Compartir</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript">
</script>
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="nvnetgroup">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
</vb:if>
and change it to:
Code:
<vb:if condition="!in_array($GLOBALS[forumid], array(191, 192, 217, 114, 216))">
<div align="right" style="height:27px;">
<a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Compartir</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript">
</script></div>
<div align="right">
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="nvnetgroup">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</div>
</vb:if>
See what that does...
Reply With Quote
  #55  
Old 08-25-2010, 01:33 AM
Alucard^'s Avatar
Alucard^ Alucard^ is offline
 
Join Date: Feb 2008
Location: Argentina
Posts: 124
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well... i solved the problem with this: http://sharethis.com/publishers/get-button-code?style=6

Using this code:

PHP Code:
<vb:if condition="!in_array($GLOBALS[forumid], array(191, 192, 217, 114, 216))">
<
div style="text-align: right; margin-bottom: 10px;">
<
span class="st_twitter_hcount" displayText="Tweet"></span><span class="st_facebook_hcount" displayText="Share"></span>
</
div>
</
vb:if> 
And this on the headinclude:

PHP Code:
<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script><script type="text/javascript">stLight.options({publisher:'dfba2cb0-5585-44ea-9c02-ab4120cee202'});</script
And work perfect, but now i have another strange problem... see this:



When i add that code of the headinclude (the scripts) appear something at the right of thanks button.

You know how to solve?

Thanks and sry for posting here but is something "related" and maybe you know what is the problem.
Reply With Quote
  #56  
Old 08-25-2010, 01:51 AM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sorry, I have no clue about that.
Reply With Quote
  #57  
Old 08-25-2010, 09:09 PM
Veer Veer is offline
 
Join Date: Feb 2006
Posts: 733
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Installed.

Code:
http://www.forum.com/threads/90953
I tried it by clicking on tweet and it is missing a SLASH in thread url.

Any help?
Reply With Quote
  #58  
Old 08-25-2010, 10:59 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Veer View Post
Installed.

Code:
http://www.forum.com/threads/90953
I tried it by clicking on tweet and it is missing a SLASH in thread url.

Any help?
See post #42 for a solution to that issue. :up:
Reply With Quote
  #59  
Old 08-26-2010, 09:50 AM
zelnik zelnik is offline
 
Join Date: Aug 2008
Posts: 374
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Well I thought I had it working but the counter seems to mess up?!

When I tweet something the counter will say "1" hit refresh and it will go back to "0" and each and every time after still "0" Any ideas?
Reply With Quote
  #60  
Old 08-26-2010, 02:29 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by zelnik View Post
Well I thought I had it working but the counter seems to mess up?!

When I tweet something the counter will say "1" hit refresh and it will go back to "0" and each and every time after still "0" Any ideas?
Hmmm... I'd imagine the issue is because before your URL is submitted Twitter 'thinks' you're on the wrong page (without the slash) so when it checks its records it sees no one has 'tweeted' that URL so the count is Zero... When you hit Tweet you actually send a link to a different (albeit correct) URL so it doesn't get counted to the right page.

Understand?

I will keep trying to figure out why you're having the initial issue since that would solve everything, but in the mean time you can display the Tweet button without the counter so it doesn't throw people off... in your code replace:

data-count="horizontal" with data-count="none"
Reply With Quote
  #61  
Old 08-26-2010, 04:52 PM
zelnik zelnik is offline
 
Join Date: Aug 2008
Posts: 374
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
Hmmm... I'd imagine the issue is because before your URL is submitted Twitter 'thinks' you're on the wrong page (without the slash) so when it checks its records it sees no one has 'tweeted' that URL so the count is Zero... When you hit Tweet you actually send a link to a different (albeit correct) URL so it doesn't get counted to the right page.

Understand?

I will keep trying to figure out why you're having the initial issue since that would solve everything, but in the mean time you can display the Tweet button without the counter so it doesn't throw people off... in your code replace:

data-count="horizontal" with data-count="none"
Perhaps it's something to do with vbseo?

BTW: when you click the number (which is 0 most of the time) it does take you to the tweeted link on Twitter.com
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 06:45 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05091 seconds
  • Memory Usage 2,454KB
  • Queries Executed 28 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (10)bbcode_code
  • (3)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (4)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (4)pagenav_pagelink
  • (1)pagenav_pagelinkrel
  • (11)post_thanks_box
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (4)postbit_attachment
  • (11)postbit_onlinestatus
  • (11)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_attachment
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete