vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.8 Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=236)
-   -   Show Thread Enhancements - Twitter - Tweet Button in SHOWTHREAD (https://vborg.vbsupport.ru/showthread.php?t=248568)

BirdOPrey5 08-13-2010 10:00 PM

Twitter - Tweet Button in SHOWTHREAD
 
1 Attachment(s)
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.

BirdOPrey5 08-14-2010 01:03 AM

To have just a Tweet button and no count use the following code instead:

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="none" data-via="JUOTnet">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</td></tr></table>
</if>
</td>

For more options check out: http://twitter.com/goodies/tweetbutton

busybeeburns 08-15-2010 10:05 AM

thanks! I'm trying also to get the Like button next to it, what code are you using overall?

BirdOPrey5 08-15-2010 01:42 PM

My exact code is:
Code:

<td align="$stylevar[right]"><if condition="$show['pagenav']">$pagenav</if>
<if condition="!in_array($GLOBALS[forumid], array(2, 3, 6, 15, 23, 24, 45))">
<table border="0">
<tr><td>
<a href="http://twitter.com/share" class="twitter-share-button" data-count="horizontal" data-via="JUOTnet">Tweet</a><script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</td><td>
<iframe src="http://www.facebook.com/plugins/like.php?href=http://www.juot.net/forums/showthread.php$session[sessionurl]?t=$threadid" &amp;show_faces=false&amp;width=350&amp;action=like&amp;colorscheme=dark&amp;height=30" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:350px; height:30px;" allowTransparency="true"></iframe>
</td></tr></table>
</if>
</td>

But I also followed most of the instructions in this facebook mod as well to get facebook to work right... in general facebook is a major PITA compared to twitter. I basically followed all instructions on the facebook mod but used the iframe instead of the built in like button because it worked for me and after days of messing with it I didn't want to risk it not working... but I think things have been straightened out now and you'd be OK in following the instructions exactly.

Brandon Sheley 08-15-2010 02:33 PM

thanks for this, I've been using the tweetmeme button, but want to switch it over to the official button soon.
this reminded me :)

Carlos X 08-15-2010 07:25 PM

I'll wait a while before implementing this. I would love to install it, but I'm concerned about security.

BirdOPrey5 08-15-2010 07:39 PM

Quote:

Originally Posted by Carlos X (Post 2084396)
I'll wait a while before implementing this. I would love to install it, but I'm concerned about security.

Security is always a valid concern although I don't see any possible way this mod could jeopardize your forum's security, it is a fairly basic JavaScript released by some of the most talented developers in the industry- probably better then vBulletin's, not meant in any way to insult vB who themselves are quite good. This mod is just Twitter's own instructions for installing their own Tweet button- I just found what I feel was the best place to put it on a vB forum... anyone is free to put this on any web page, forum or not... If, and I stress IF, there was ever any security issue with this mod it would:
1) Be corrected by Twitter ASAP with no work necessary on your part since this links to twitter's server to download the script.
and
2) Would be limited to, perhaps, security of your twitter account- not the forum in general.

Carlos X 08-15-2010 08:12 PM

Okie dokie.

So now I'm going to be geared towards SEO because I've got vbSEO installed.

And this includes your version of the facebook "like."

BirdOPrey5 08-15-2010 08:41 PM

This does not include facebook 'like' - I only posted that code in response to a specific question. Copying it won't help you unless you follow the instructions in the facebook mod I linked to.

MylesM 08-17-2010 10:47 PM

For some reason the counter keeps getting reset to 0...

When ever I click on the counter to search Twitter, it says "No results found" - but when I go to my twitter profile page I can see what I've tweeted.

I'm running 3.8.6 with C-Logic SEO if that helps.


All times are GMT. The time now is 09:14 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02457 seconds
  • Memory Usage 1,751KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (6)bbcode_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete