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

Reply
 
Thread Tools
Add Tweet, Google+ FB like/Share buttons in your threads Details »»
Add Tweet, Google+ FB like/Share buttons in your threads
Version: 1.00, by ShawneyJ ShawneyJ is offline
Developer Last Online: Nov 2023 Show Printable Version Email this Page

Category: Show Thread Enhancements - Version: 3.8.7 Rating:
Released: 06-13-2014 Last Update: Never Installs: 14
Template Edits
 
No support by the author.

Im basically adding this Template modification for safe keeping if thats ok by the staff.
This is pretty simply and does what i need it to do for my forums.
As the title kinda stats, you can add "Tweet, Google+ FB like/Share" share buttons under the post title of your threads and, or above signature. These 2 places i find looks neater and kinda more effective. You can chose to place your code anywhere in post_bit that fits your needs. FYI: This only shares the URL of the Thread.

Ok lets get to it.

In your Header Template, add this Code to the very Top:
Code:
<div id="fb-root"></div>
<script type="text/javascript">(function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) return;
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<script type="text/javascript">
  (function() {
    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
    po.src = 'https://apis.google.com/js/platform.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>
And Save.

In Your Additional CSS Add the following:
Code:
.social-buttons {
margin: 0 0 0 0;
}

#twitterbutton, #likebutton, #plusonebutton, #linkedinshare {
float: left;
display: block;
}

#plusonebutton {
margin-left: 15px;
margin-top: 0px;
}

#likebutton {
margin-top:0px;
margin-left: 15px;
overflow: hidden !important;
}
Ok thats it for header and CSS, you don't need to change the above codes for any of the following options.

Now its time to place your Share Buttons into your Threads.
You have 1 of 3 Options on where you would like to add your Share Buttons.
1. Below Post Title
2. Above Signature
3. Next To Edit Buttons.

Option 1.
How to add Share Buttons Below Post Title:

Find in Template postbit_legacy:
Code:
			<!-- / icon and title -->
		</if>
Add Below:
Code:
<if condition="(($post[postcount] % $vboptions[maxposts] == 1))">
<if condition="THIS_SCRIPT =='showthread'">
<div class="social-buttons">

<div id="twitterbutton"><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-via="YOUR-TWITTER-NAME">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></div>

<div id="plusonebutton"><div class="g-plusone" data-size="medium" data-annotation="none"></div>
</div>

<div id="likebutton"><script src="http://connect.facebook.net/es_US/all.js#xfbml=1"></script><fb:like href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" send="true" width="400" show_faces="false" font=""></fb:like></div>
</div><br /><br />
</if>
</if>
And Save.

Option 2.
How to add Share Buttons above your Signature:

In postbit_legacy Template, Search for:
Code:
<if condition="$post['signature']">
Add Above:
Code:
<if condition="(($post[postcount] % $vboptions[maxposts] == 1))">
<if condition="THIS_SCRIPT =='showthread'">
<br />
<div class="social-single">

<div id="twitterbutton"><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-via="YOUR-TWITTER-NAME">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></div>

<div id="plusonebutton"><div class="g-plusone" data-size="medium" data-annotation="none"></div>
</div>

<div id="likebutton"><div id="fb-root"></div><script src="http://connect.facebook.net/es_US/all.js#xfbml=1"></script><fb:like href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" send="true" width="400" show_faces="false" font=""></fb:like></div>
</div>
<br />
<br />
</if>
</if>
And Save.

This is only if you have modified Signature Coding in your postbit.
Try searching in postbit_legacy Template for:
Code:
$ad_location[ad_showthread_firstpost_sig]
And add the code below it.

Option 3.
How to add Share Buttons below next to the Edit, Quote Buttons etc:

Find in your postbit_legacy Template:
Code:
<!-- controls -->
And add Above, this Code:
Code:
<if condition="(($post[postcount] % $vboptions[maxposts] == 1))">
<if condition="THIS_SCRIPT =='showthread'">
<div class="social-single">

<div id="twitterbutton"><a href="https://twitter.com/share" class="twitter-share-button" data-count="none" data-via="YOUR-TWITTER-NAME">Tweet</a><script type="text/javascript" src="//platform.twitter.com/widgets.js"></script></div>

<div id="plusonebutton"><div class="g-plusone" data-size="medium" data-annotation="none"></div>
</div>

<div id="likebutton"><div id="fb-root"></div><script src="http://connect.facebook.net/es_US/all.js#xfbml=1"></script><fb:like href="$vboptions[bburl]/showthread.php?t=$thread[threadid]" send="true" width="400" show_faces="false" font=""></fb:like></div>
</div>
</if>
</if>
And Save.

Hide Share Buttons in certain Forums:

You would simply use these lines around the Code above and change x to Forums ID:
Code:
<if condition="!in_array($GLOBALS[forumid], array(x,x,x))">
Full Share Button Code
</if>

For Example, if i wanted to hide the Share Buttons in my Staff Forums, i would place in the Forums ID 43 and 44. My code would look like this:
Code:
<if condition="!in_array($GLOBALS[forumid], array(43,44))">
Full Share Button Code
</if>
Screenshot Added.

Haven't tried this on normal post bit template but pretty sure it will work.
You can add extra buttons to this code for your site, like Pin It etc.

And hope this works for anyone that actually uses it.

Thanks for marking Installed!

Screenshots added of All Placements added to this post.
Demo Test Site: DEMO.

Also don't forget to add your own Twitter name "YOUR-TWITTER-NAME" to whatever yours is!

Updated: 30/06/2014.
Fixed the following issues:
validator.w3.org was picking on an small error in the facebook header code - Fixed.
There was an issue with the Like Button, every time you clicked Like, a box would appear. No more Box! - Fixed.
The <br's were in the wrong spot in the codes effecting 2nd, 3rd, 4th posts etc - Fixed.
When someone clicked the FB Like Button, the line of text would increase in character and cause 2 lines - Fixed.

Aware of a small issue sometime a small with line appears behine the FB Like Button when Clicking Like. Works fine and isn't a real issue, but will try to find a fix anyways.

Screenshots

File Type: png demo-top.png (332.3 KB, 0 views)
File Type: png demo-bottom.png (210.4 KB, 0 views)
File Type: png demo-next-to-edit.png (392.3 KB, 0 views)
File Type: png Hidden-Buttons.png (368.1 KB, 0 views)

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.
3 благодарности(ей) от:
blind-eddie, Boosted Euro, tbworld

Comments
  #22  
Old 08-22-2014, 04:26 AM
tini_lam tini_lam is offline
 
Join Date: Dec 2009
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

have support on vbb 4.2.x ??
Reply With Quote
  #23  
Old 08-22-2014, 04:40 AM
ShawneyJ's Avatar
ShawneyJ ShawneyJ is offline
 
Join Date: Jul 2006
Location: Australia
Posts: 1,758
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tini_lam View Post
have support on vbb 4.2.x ??
this would have to be slightly recoded for vb4.

although there is something similar for vb4, but atm i cant find it.

EDIT: actually. just a quick test on vb4 changing the <if to <vb:if the icons do show.
although i cant say it all works without further testing.
if i can get them working smoothly i will add a how to...to my first post.
Attached Images
File Type: png testvb4.png (34.9 KB, 0 views)
Reply With Quote
  #24  
Old 08-25-2014, 06:08 AM
tini_lam tini_lam is offline
 
Join Date: Dec 2009
Posts: 48
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

it show in safari Ipad have error. content in first post blank...
Reply With Quote
  #25  
Old 08-26-2014, 03:27 AM
ShawneyJ's Avatar
ShawneyJ ShawneyJ is offline
 
Join Date: Jul 2006
Location: Australia
Posts: 1,758
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by tini_lam View Post
it show in safari Ipad have error. content in first post blank...
vb3 or vb4?
Reply With Quote
  #26  
Old 01-12-2015, 01:20 AM
compact compact is offline
 
Join Date: Jan 2003
Posts: 47
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Great mod, thanks! A questions though. How can i change the color of the text where it says "Be the first of your friends to like this." The default is in black but i need it in white. Thanks.
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 09:07 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.03980 seconds
  • Memory Usage 2,304KB
  • Queries Executed 21 (?)
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
  • (11)bbcode_code
  • (2)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
  • (2)pagenav_pagelink
  • (6)post_thanks_box
  • (3)post_thanks_box_bit
  • (6)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (6)post_thanks_postbit_info
  • (5)postbit
  • (5)postbit_attachment
  • (6)postbit_onlinestatus
  • (6)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