Go Back   vb.org Archive > vBulletin Modifications > vBulletin 4.x Modifications > vBulletin 4.x 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: 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
  #102  
Old 09-23-2010, 04:25 PM
ceho ceho is offline
 
Join Date: Mar 2008
Location: Germany
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I installed it on a customized 4.0.7 using the I Like button and it works perfect, thank you very much.

However, it looks I am a bit slow tonight ;-), is it possible to have the twitter button and cound left to the FB button? I am a bit confused with the code, maybe you can help me?

Thanks a lot!
Reply With Quote
  #103  
Old 09-23-2010, 04:52 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Although it's counter-intuitive if you just swap the code location with the facebook like button the Tweet button will be to the left of the FB button.

Use this as a replacement instead of the original directions:

Code:
{vb:raw fblikebutton}<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>
Reply With Quote
  #104  
Old 09-23-2010, 06:30 PM
ceho ceho is offline
 
Join Date: Mar 2008
Location: Germany
Posts: 110
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That was too easy ;-). Thank you very much and I will consider your advice for sure!
Reply With Quote
  #105  
Old 09-23-2010, 09:24 PM
Tony_FPM Tony_FPM is offline
 
Join Date: Feb 2005
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
That's weird but this should fix it...

Edit your headinclude template:

Find:
Code:
		<meta name="description" content="{vb:raw vboptions.description}" />
</vb:if>
Below it Add:
Code:
<vb:if condition="THIS_SCRIPT == 'showthread'">
<link rel="canonical" href="http://www.example.com/forum/{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}" />
</vb:if>
Make sure you change http://www.example.com/forum/ to the URL to your own forums, whatever is before "showthread.php..." when you are viewing a thread. (In the example given it would be: http://www.baghdad4ever.net/vb/)

This will include a canonical link on your threads (and only threads) which over-rides the URL passed to Twitter, with hopefully, the right one now...

If this doesn't work please give me a link to your forums so I can see what is up...
Done but still not working. Now i get http://www.freakpyromaniacs.com/foru...uot-16-09-2010 when i click the link in the tweet and it is missing again a / ....http://www.freakpyromaniacs.com/forum/forum.phpshow/thread.php?28916-Bunker-met-vuurwerk-in-Duitsland-quot-ontploft-quot-16-09-2010

Help me please...

This is my template code
PHP Code:
<meta http-equiv="Content-Type" content="text/html; charset={vb:stylevar charset}" />
<
meta id="e_vb_meta_bburl" name="vb_meta_bburl" content="{vb:raw vboptions.bburl}" />
<
base href="{vb:raw vboptions.bburl}/" /><!--[if IE]></base><![endif]-->
<
meta name="generator" content="vBulletin {vb:raw vboptions.templateversion}" />

<
vb:if condition="$show['threadinfo']">

<
vb:elseif condition="$show['foruminfo']" />
        <
meta name="keywords" content="{vb:raw foruminfo.title_clean}, {vb:raw vboptions.keywords}" />
        <
meta name="description" content="<vb:if condition="$pagenumber 1">{vb:rawphrase page_x, {vb:raw pagenumber}}-</vb:if>{vb:raw foruminfo.description_clean}" />
<
vb:else />
        <
meta name="keywords" content="{vb:raw vboptions.keywords}" />
        <
meta name="description" content="{vb:raw vboptions.description}" />
</
vb:if>
<
vb:if condition="THIS_SCRIPT == 'showthread'">
<
link rel="canonical" href="http://www.freakpyromaniacs.com/forum/forum.php{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}" />
</
vb:if>

<
vb:if condition="$show['fb_opengraph']">
    {
vb:raw facebook_opengraph}
</
vb:if>

<
script type="text/javascript" src="{vb:stylevar yuipath}/yuiloader-dom-event/yuiloader-dom-event.js?v={vb:raw vboptions.simpleversion}"></script>
<
script type="text/javascript" src="{vb:stylevar yuipath}/connection/connection-min.js?v={vb:raw vboptions.simpleversion}"></script>
<
script type="text/javascript">
<!--
    var 
SESSIONURL "{vb:raw session.sessionurl_js}";
    var 
SECURITYTOKEN "{vb:raw bbuserinfo.securitytoken}";
    var 
IMGDIR_MISC "{vb:stylevar imgdir_misc}";
    var 
IMGDIR_BUTTON "{vb:stylevar imgdir_button}";
    var 
vb_disable_ajax parseInt("{vb:raw vboptions.disable_ajax}"10);
    var 
SIMPLEVERSION "{vb:raw vboptions.simpleversion}";
    var 
BBURL "{vb:raw vboptions.bburl}";
    var 
LOGGEDIN = {vb:raw bbuserinfo.userid} > true false;
    var 
THIS_SCRIPT "{vb:raw this_script}";
        var 
RELPATH "{vb:raw relpath}";
// -->
</script>
<
script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-core.js?v={vb:raw vboptions.simpleversion}"></script>
{
vb:raw template_hook.headinclude_javascript}

<
vb:if condition="$vboptions['externalrss']">
    <
link rel="alternate" type="application/rss+xml" title="{vb:raw vboptions.bbtitle} {vb:rawphrase rss_feed}" href="{vb:raw vboptions.bburl}/external.php?type=RSS2" />
    <
vb:if condition="$show['foruminfo'] OR $show['threadinfo']">
        <
link rel="alternate" type="application/rss+xml" title="{vb:raw vboptions.bbtitle} - {vb:raw foruminfo.title_clean} - {vb:rawphrase rss_feed}" href="{vb:raw vboptions.bburl}/external.php?type=RSS2&amp;forumids={vb:raw foruminfo.forumid}" />
    </
vb:if>
</
vb:if>

<
vb:if condition="$vboptions['storecssasfile']">
    {
vb:cssfile main-rollup.css}
        {
vb:raw template_hook.custom_css_links}
<
vb:else />
    {
vb:cssfile bbcode.css,editor.css,popupmenu.css,reset-fonts.css,vbulletin.css,vbulletin-chrome.css,vbulletin-formcontrols.css{vb:raw template_hook.custom_css_list}}
</
vb:if>
{
vb:raw template_hook.headinclude_css
Reply With Quote
  #106  
Old 09-23-2010, 09:50 PM
BirdOPrey5's Avatar
BirdOPrey5 BirdOPrey5 is offline
Senior Member
 
Join Date: Jun 2008
Location: New York
Posts: 10,610
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

^^^^

Your issue is with the line:

HTML Code:
<link rel="canonical" href="http://www.freakpyromaniacs.com/forum/forum.php{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}" />
Change it to:

HTML Code:
<link rel="canonical" href="http://www.freakpyromaniacs.com/forum/{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}" />
and you should be set. :up:

You had an extra "forum.php" in that line...
Reply With Quote
  #107  
Old 09-23-2010, 10:48 PM
Tony_FPM Tony_FPM is offline
 
Join Date: Feb 2005
Posts: 64
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
^^^^

Your issue is with the line:

HTML Code:
<link rel="canonical" href="http://www.freakpyromaniacs.com/forum/forum.php{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}" />
Change it to:

HTML Code:
<link rel="canonical" href="http://www.freakpyromaniacs.com/forum/{vb:link thread, {vb:raw thread}, {vb:raw pageinfo_post}}" />
and you should be set. :up:

You had an extra "forum.php" in that line...
Thanks. It works now!
Reply With Quote
  #108  
Old 09-26-2010, 08:12 PM
swiftor's Avatar
swiftor swiftor is offline
 
Join Date: Nov 2008
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You didn't mention this working for blogs, but I tried anyway in the blog_show_entry template, and it appears on two separate lines. Any chance of instructing on how to make it look nicer on one line?

Attachment 122351
Reply With Quote
  #109  
Old 09-26-2010, 10:09 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 don't have the vB4 Suite so I can't test out too much. I downloaded a copy of your blog and played with some settings- if you completely remove the <div> tag around the Twitter code then both buttons show up on the same line, but the twitter button is a few pixels higher than the Facebook button. I haven't figured out a way to correct this without using a div tag, if I had a suite license I would try some more but if you play with it hopefully you can figure it out.

Also I noticed you didn't put your Twitter username into the code, your username is still set to "YOUR_TWITTER_USERNAME."
Reply With Quote
  #110  
Old 09-27-2010, 02:40 AM
swiftor's Avatar
swiftor swiftor is offline
 
Join Date: Nov 2008
Posts: 118
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

thanks for that!
Reply With Quote
  #111  
Old 09-27-2010, 11:29 AM
subvertbeats subvertbeats is offline
 
Join Date: Mar 2009
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by BirdOPrey5 View Post
Understood. Is this problem currently affecting you personally? (Just trying to prioritize things.)
Hi Joe

Id be hard pressed to say that with any confidence.
Basically, I just dont know if its affecting us. I think it might be but can't say for sure.

All the best,
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 09:10 AM.


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.05317 seconds
  • Memory Usage 2,385KB
  • 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
  • (4)bbcode_html
  • (1)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_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