Go Back   vb.org Archive > vBulletin Modifications > vBulletin 3.8 Modifications > vBulletin 3.8 Template Modifications

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: 3.8.x Rating:
Released: 08-13-2010 Last Update: 08-20-2010 Installs: 57
Template Edits
Re-useable Code Translations  
No support by the author.

Twitter released their new TWEET button.

Live Demo: http://www.juot.net/forums/showthread.php?t=41185
(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 / Opera / Safari.

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

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

Find:
Code:
<if condition="$show['pagenav']"><td align="$stylevar[right]">$pagenav</td></if>
Replace With:
Code:
<td align="$stylevar[right]"><if condition="$show['pagenav']">$pagenav</if>
<if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
<table border="0">
<tr><td>
<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>
</td></tr></table>
</if>
</td>
Change the X, Y, Z in the second 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:
<if condition="!in_array($GLOBALS[forumid], array(2, 5, 9))">
<if condition="!in_array($GLOBALS[forumid], array(7))">
<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:
<if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
and 
</if> (The second one)
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.

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. I will add more options in later posts.

Note- My Screenshot also has the Facebook Like button available as a separate mod here by someone else. If you don't have the facebook like button your Tweet button will be on the right of the page. There is also a basic skin screen shot.

Please click Install if you use this.

NEW UPDATE!!!

Use this code instead it will force the correct URL to Twitter and solve the issue with a different URL being tweeted if thread is tweeted as soon as it's posted.

Code:
<td align="$stylevar[right]"><if condition="$show['pagenav']">$pagenav</if>
<if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
<table border="0">
<tr><td>
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="YOUR_TWITTER_USERNAME" data-url="$vboptions[bburl]/showthread.php?t=$thread[threadid]">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</td></tr></table>
</if>
</td>
Be sure to replace "YOUR_TWITTER_USERNAME" and "X, Y, Z" as described above.

Download Now

File Type: txt tweet_button_vb3.txt (2.3 KB, 151 views)

Screenshots

File Type: jpg ss_twitter.jpg (180.2 KB, 0 views)
File Type: jpg ss_twitter_badic.jpg (82.3 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
Благодарность от:
mary_rose082198

Comments
  #12  
Old 08-17-2010, 11:48 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'd bet the SEO is the problem... the link being submitted to twitter is the non SEO link, but when you visit the thread you are visiting from a different URL so the counter is zero and always will be.

I noticed the same issue if you tweet a post immediately after you submit it... when you submit a post the URL has the post number appended to the end of the URL, when you browse the thread from a forum though there is no post number just thread id so it's a different URL so the counter is different.

The way around this I believe would be to use a canonical link tag in the header but that would be very bad for your SEO purposes because you want the 'seo optimized' url not the vb default one.
Reply With Quote
  #13  
Old 08-18-2010, 08:28 AM
MylesM MylesM is offline
 
Join Date: Aug 2009
Posts: 56
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
I'd bet the SEO is the problem... the link being submitted to twitter is the non SEO link, but when you visit the thread you are visiting from a different URL so the counter is zero and always will be.

I noticed the same issue if you tweet a post immediately after you submit it... when you submit a post the URL has the post number appended to the end of the URL, when you browse the thread from a forum though there is no post number just thread id so it's a different URL so the counter is different.

The way around this I believe would be to use a canonical link tag in the header but that would be very bad for your SEO purposes because you want the 'seo optimized' url not the vb default one.
Thanks for the reply.

For now, I've removed the counter from the Tweet button. It's still a great modification none the less.
Reply With Quote
  #14  
Old 08-18-2010, 08:38 AM
ShawneyJ's Avatar
ShawneyJ ShawneyJ is offline
 
Join Date: Jul 2006
Location: Australia
Posts: 1,758
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

this is great thanks
Reply With Quote
  #15  
Old 08-21-2010, 06:46 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 anyone is using this like I do with the Facebook Like button I added the following code so that the tweet button is centered vertically with the facebook button...

put a <div> around the tweet button code-
Code:
<div style="padding-bottom:8px;"> Original Tweet Button Code Here </div>
Reply With Quote
  #16  
Old 08-29-2010, 09:32 PM
Eryeal Eryeal is offline
 
Join Date: May 2006
Posts: 24
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have a very odd problem .. The twitter icon doesn't show up in 2 of my forums on any threads .. there is absolutely no difference in these forums in the Forum Manager, or Forum Permissions. They are set up the exact same way - the only difference is the name of the forum that I can tell. The icon just doesn't show up at all. Any ideas?
Reply With Quote
  #17  
Old 08-29-2010, 10:06 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 Eryeal View Post
I have a very odd problem .. The twitter icon doesn't show up in 2 of my forums on any threads .. there is absolutely no difference in these forums in the Forum Manager, or Forum Permissions. They are set up the exact same way - the only difference is the name of the forum that I can tell. The icon just doesn't show up at all. Any ideas?
If you look at the code you use there's this line:
Code:
<if condition="!in_array($GLOBALS[forumid], array(X, Y, Z))">
You need to replace X, Y, and Z with forumid numbers of forums in which you don't want to show the tweet button, like for example:

Code:
<if condition="!in_array($GLOBALS[forumid], array(11, 12, 20, 58))">
or if just 1 forum to not display the button in, for example:

Code:
<if condition="!in_array($GLOBALS[forumid], array(6))">
My guess is the forum's it's not showing for are listed in your IF statement...

If you don't have any forums in which you don't want to display the tweet button I give yo the two lines to remove in the instructions.
Reply With Quote
  #18  
Old 09-04-2010, 10:35 AM
metalguy639 metalguy639 is offline
 
Join Date: Dec 2008
Posts: 501
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks this is cool. I instantly got traffic when I tweeted my threads. not sure if they are bots or real people but at least the links are getting out there
Reply With Quote
  #19  
Old 09-05-2010, 10:38 PM
Prisoner Prisoner is offline
 
Join Date: Aug 2005
Location: Central Texas
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I added this and the Facebook button at the same time and people freaked out at seeing their Facebook (Real) name on the forum. Even though only their friends can see that, it made them uncomfortable.

I may add the Tweet button back on.
Reply With Quote
  #20  
Old 09-05-2010, 10:55 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 Prisoner View Post
I added this and the Facebook button at the same time and people freaked out at seeing their Facebook (Real) name on the forum. Even though only their friends can see that, it made them uncomfortable.

I may add the Tweet button back on.
Some people will complain about anything- if they really understood that only people who ALREADY knew their name would see their name they'd have nothing to complain about... but that said the Twitter button doesn't show any personal info to anyone besides the twitter account of the forum admin which you want people to know.
Reply With Quote
  #21  
Old 09-05-2010, 11:04 PM
Prisoner Prisoner is offline
 
Join Date: Aug 2005
Location: Central Texas
Posts: 89
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I know and I tried to explain it, but I know that if they aren't comfortable with it, they won't use it.

On my forum, there are a lot of local teachers and city workers who post about their jobs and they are just paranoid that their bosses and co-workers will be able to identify them. If the Facebook note showed that their Username liked it, they would probably be ok with it.

I was hoping to use it to generate traffic to the site.

Adding the Tweet link back now.

Thanks
Reply With Quote
Reply

Thread Tools

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 11:25 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.07010 seconds
  • Memory Usage 2,346KB
  • Queries Executed 26 (?)
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
  • (8)bbcode_code
  • (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
  • (3)pagenav_pagelink
  • (11)post_thanks_box
  • (1)post_thanks_box_bit
  • (11)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (11)post_thanks_postbit_info
  • (10)postbit
  • (3)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_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
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • 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