Advertisement:

Author Topic: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts  (Read 117051 times)

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
If you're like me, and just like having social media options on your site, well then check this out.

If you want to add quick social sharing buttons from Google, Facebook, and Twitter to all your posts, just add this code in your theme's Display.template.php. Note that if you have a custom theme without its own Display.template.php, you only need to modify the one in the default directory.

Code: (find) [Select]
<h3 class="catbg">
<img src="', $settings['images_url'], '/topic/', $context['class'], '.gif" align="bottom" alt="" />
<span id="author">', $txt['author'], '</span>
', $txt['topic'], ': ', $context['subject'], ' &nbsp;(', $txt['read'], ' ', $context['num_views'], ' ', $txt['times'], ')
</h3>
Code: (replace with) [Select]
<h3 class="catbg">
<img src="', $settings['images_url'], '/topic/', $context['class'], '.gif" align="bottom" alt="" />
<span id="author">', $txt['author'], '</span>
', $txt['topic'], ': ', $context['subject'], ' &nbsp;(', $txt['read'], ' ', $context['num_views'], ' ', $txt['times'], ')

<!-- Facebook -->
<span class="floatright" style="margin: 6px;" id="facebook">
<div id="fb-root"></div>
<fb:like href="', $scripturl, '?topic=', $context['current_topic'], '" send="false" layout="button_count" width="100" show_faces="false" font=""></fb:like>
</span>

<!-- Twitter -->
<span class="floatright" style="margin: 6px;" id="twitter">
<a href="http://twitter.com/share" class="twitter-share-button" data-url="', $scripturl, '?topic=', $context['current_topic'], '" data-text="CUSTOM_TWEET_TEXT" data-count="horizontal" data-via="PRIMARY_TWITTER_ACCOUNT" data-related="SECONDARY_TWITTER_ACCOUNT">Tweet</a>
</span>

<!-- Google Plus -->
<span class="floatright" style="margin: 6px;" id="gplus">
<div class="g-plusone" data-size="medium" data-annotation="inline" data-width="120" data-href="', $scripturl, '?topic=', $context['current_topic'], '"></div>
</span>
</h3>

Now, in order to use Facebook, Twitter, and Google Plus buttons, you'll need to add this to your index.template.php. You will need to modify this for every theme you wish to use the buttons on.

Code: (find) [Select]
function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
</body></html>';
}

Code: (replace with) [Select]
function template_html_below()
{
global $context, $settings, $options, $scripturl, $txt, $modSettings;

echo '
<!-- Facebook Share -->
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>

<!-- Twitter Share -->
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>

<!-- Google Plus -->
<script type="text/javascript">
  (function() {
var po = document.createElement(\'script\'); po.type = \'text/javascript\'; po.async = true;
po.src = \'https://apis.google.com/js/plusone.js\';
var s = document.getElementsByTagName(\'script\')[0]; s.parentNode.insertBefore(po, s);
  })();
</script>

</body></html>';
}

You can replace the following vars with what you like:
CUSTOM_TWEET_TEXT = The text you want to tweet. Things such as "Check this out: ', $context['subject'], '" work nicely. You can alternatively leave it empty to use the page's title.
PRIMARY_TWITTER_ACCOUNT = The primary account you want to make the tweet via. Leave out the @.
SECONDARY_TWITTER_ACCOUNT = Same as above, but you can leave this one empty.

Screenshot:


It's that simple really. This is mainly for those who just want a quick hack without clouding up their installed mods list. :)

NOTE: This code is provided "as-is", and no support will be given as I do not have the time. Thank you for understanding :)
« Last Edit: June 10, 2012, 01:40:46 AM by JBlaze »
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline 4b11l

  • Jr. Member
  • **
  • Posts: 355
Re: [TIP/TRICK] Adding Twitter "Share" Button To Posts
« Reply #1 on: June 16, 2011, 06:38:12 PM »
Hello, does this tip only post to one account such as the website account? Or is it like other service where the user is able to login their details and post to their twitter?

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: [TIP/TRICK] Adding Twitter "Share" Button To Posts
« Reply #2 on: June 16, 2011, 06:45:44 PM »
Hello, does this tip only post to one account such as the website account? Or is it like other service where the user is able to login their details and post to their twitter?
It allows you to input the account you wish for people to follow as well as a secondary account for people to follow. It does not however make tweets through any given account. It just allows member to tweet share the link.
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline 4b11l

  • Jr. Member
  • **
  • Posts: 355
Re: [TIP/TRICK] Adding Twitter "Share" Button To Posts
« Reply #3 on: June 16, 2011, 06:51:26 PM »
Ah, I see. Thanks.

Offline 4b11l

  • Jr. Member
  • **
  • Posts: 355
Re: [TIP/TRICK] Adding Twitter "Share" Button To Posts
« Reply #4 on: June 17, 2011, 02:36:54 AM »
I just tested it out and it was exactly what I was looking for! Thanks JBlaze, I think it was just that I didn't know how to explain it that I was confused in it's purpose.

It popped up a login for you to login your twitter details and it'll post to that account the custom message and link. I thought it automatically posted to the account listed as the primary.

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: [TIP/TRICK] Adding Twitter "Share" Button To Posts
« Reply #5 on: June 17, 2011, 03:07:04 AM »
No problem :)
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline Robert.

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 4,074
  • Gender: Male
    • nedroden on GitHub
Re: [TIP/TRICK] Adding Twitter "Share" Button To Posts
« Reply #6 on: June 17, 2011, 04:47:55 AM »
Thanks for the tip JBlaze :)
Software Engineering student
DraiWiki | Project Alpha

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,919
  • Gender: Male

Offline lucas-ruroken

  • SMF Hero
  • ******
  • Posts: 4,907
  • Gender: Male
  • Adk Developer
    • lucas.ruroken on Facebook
    • lucasruroken on GitHub
Re: [TIP/TRICK] Adding Twitter "Share" Button To Posts
« Reply #8 on: June 19, 2011, 09:14:10 PM »
easy and useful ;) Thanks
Adk Portal 3.1 is coming....

Design your universe!

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #9 on: June 22, 2011, 01:09:44 PM »
! Added Facebook Like button
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline Mbravo

  • Newbie
  • *
  • Posts: 1
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #10 on: July 01, 2011, 08:52:23 AM »
Thanks for increase my knowledge ,it such a wonderful idea for sharing.

Offline MarcusJ

  • Jr. Member
  • **
  • Posts: 162
  • Gender: Male
  • SMF Junkie
    • Simjunkies.org
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #11 on: July 01, 2011, 02:47:08 PM »
Can someone please explain how I can use the following from  or something similar to place the Google +1 button along side the Twitter and Facebook icons?  I have tried myself, but can't get it to work.   :-\

Also as a side note.  My forum is set to a fixed width of 1024px.  Any title with more than a few words causes the twitter button to vanish, but the Facebook like button remains.


Code: [Select]
if ($message['id'] == $context['topic_first_message'] )
{
echo '<g:plusone href="' . $scripturl . '?topic=' . $context['current_topic'] . '" size="small"></g:plusone>
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>';
}
      



Offline 8hoursale

  • Newbie
  • *
  • Posts: 3
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #12 on: July 23, 2011, 10:19:42 AM »
I have SMF 1.1 and the Display Template looks a little different than this one does. Can this code be modified to work with 1.1?

Thank you!

Offline aelmiger

  • Jr. Member
  • **
  • Posts: 253
  • Gender: Male
    • Distrito Japonés
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #13 on: July 27, 2011, 12:17:20 AM »
Hello friend, thank you very much for any modification, but it happens that when I give a twitter, will not be adding the counter. How I can do to make this go adding the twitter done?

Thank you very much for the help

Sorry for my bad english

Offline mijo

  • Semi-Newbie
  • *
  • Posts: 56
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #14 on: August 01, 2011, 04:39:32 PM »
How to modify to make this work in 1.1.14 or is there some ready TIP to add Facebook Like button in 1.1.4..

Offline Monkey50

  • Jr. Member
  • **
  • Posts: 180
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #15 on: August 04, 2011, 12:09:21 PM »
how do i find the folder and how wouold i add google plus with that.

Offline phantomm

  • Sophist Member
  • *****
  • Posts: 1,064
  • Gender: Male
    • pages/smfpl/171860759503032 on Facebook
    • Polish ElkArte community
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #16 on: August 05, 2011, 06:24:16 AM »
Nice tip, but i have one OT question. What's the name of this theme (from screenshot from first post) ?
Polskie wsparcie SMF na simplemachines.org

My mods

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #17 on: August 05, 2011, 06:52:31 AM »
Nice tip, but i have one OT question. What's the name of this theme (from screenshot from first post) ?
It's a modified version of Dziner's Inferno theme.

Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline Hasanudin

  • Semi-Newbie
  • *
  • Posts: 24
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #18 on: August 07, 2011, 11:04:28 AM »
thank you :)

Offline globalwalyy

  • Newbie
  • *
  • Posts: 1
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #19 on: September 19, 2011, 05:08:48 AM »
hello thanks for this script, but i immediately i did this it destroy everything i have to rest it back pls help me out i think am lost somewhere

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #20 on: September 19, 2011, 08:53:17 AM »
hello thanks for this script, but i immediately i did this it destroy everything i have to rest it back pls help me out i think am lost somewhere
Destroy everything how? Have a screenshot?
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline ~Dragon~

  • Jr. Member
  • **
  • Posts: 301
  • Gender: Male
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #21 on: October 19, 2011, 05:18:47 AM »
Thank you so much tutorial posts
Please do not PM or email, Thank respond please post fast to SMF!

Offline stang7043

  • Semi-Newbie
  • *
  • Posts: 20
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #22 on: November 03, 2011, 01:52:27 PM »
How to modify to make this work in 1.1.14 or is there some ready TIP to add Facebook Like button in 1.1.4..

I am looking for the same ... Did anyone let you know how to modify this for 1.1.14 ?

Offline Sir Charles

  • Semi-Newbie
  • *
  • Posts: 31
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #23 on: December 10, 2011, 07:02:44 PM »
Is there a way of using this in Simpleportal to display on articles? It works great on my topics but I would like them on my portal articles too if possible.

Offline Jeet Chowdhury

  • Jr. Member
  • **
  • Posts: 239
  • Gender: Male
  • Running SMF 2.0.2
    • MuSKiL AShaN
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #24 on: January 10, 2012, 02:45:50 AM »
see this:

http://muskilashan.com/index.php?topic=838.0

horizontal scroll bar come in browser with this code....

how to remove this unnecessary scroll bar?
« Last Edit: January 10, 2012, 03:30:30 AM by Jeet Chowdhury »

Offline Jeet Chowdhury

  • Jr. Member
  • **
  • Posts: 239
  • Gender: Male
  • Running SMF 2.0.2
    • MuSKiL AShaN
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #25 on: January 10, 2012, 01:02:24 PM »
bump...

Offline Home 4 Answers

  • Newbie
  • *
  • Posts: 8
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #26 on: February 01, 2012, 01:49:19 AM »
For the FB like do I need to add the og tags?
If so any heads up on accomplishing this?

Thanks heaps!

Offline -[Reece]-

  • Newbie
  • *
  • Posts: 9
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #27 on: February 01, 2012, 07:14:11 AM »
Very nice, I'm now able to remove two mods!

Thanks a bunch.

Offline Farmacija

  • Full Member
  • ***
  • Posts: 611
  • Gender: Male
  • Farmacija forum www.farmaceuti.com
    • Pharmacy forum
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #28 on: February 04, 2012, 02:46:56 PM »
it works, thank you!

For adding gplus button beside twitter and facebook

Code: [Select]
<span class="floatright" style="margin: 6px;" id="gplus">
<g:plusone href="' . $scripturl . '?topic=' . $context['current_topic'] . '" size="medium"></g:plusone>
<script type="text/javascript" src="http://apis.google.com/js/plusone.js"></script>
</span>
« Last Edit: February 04, 2012, 03:23:13 PM by Farmacija »

Offline userquote

  • Newbie
  • *
  • Posts: 8
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #29 on: February 19, 2012, 10:46:17 PM »
Thank you. It worked beautifully at my website.  :P

Offline glennk

  • Sr. Member
  • ****
  • Posts: 899
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #30 on: April 13, 2012, 02:24:57 PM »
Hi guys, this is good. But I have a problem. Once I click like, it opens a box for me to comment ?? However the box can hardly be seen as it stays within the restraints of the blue bar, ie the blue bar does not expand to the size of the comments box.

Also Is there a way to make the icons bigger and have them somewhere more prominant, perhaps within the post just before the opening sentence ??

Offline BinkyM

  • Semi-Newbie
  • *
  • Posts: 49
  • Gender: Female
  • I've been running forums since 1987 (not a typo!).
    • @lilMMAsweetie on Twitter
    • Snarkish
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #31 on: April 24, 2012, 12:46:43 PM »
Quote
just add this code in your theme's Display.template.php

I hate sounding like a noob, but in this case, I'm an SMF noob. The theme I created doesn't have its own Display.template.php. Should it? If so, where should I grab it from?

Thanks for the tip,

Binky

TheListener

  • Guest
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #32 on: April 24, 2012, 12:51:25 PM »
Quote
just add this code in your theme's Display.template.php

I hate sounding like a noob, but in this case, I'm an SMF noob. The theme I created doesn't have its own Display.template.php. Should it? If so, where should I grab it from?

Thanks for the tip,

Binky

If the theme you use doesn't have its own display.template then try the default one.

Offline BinkyM

  • Semi-Newbie
  • *
  • Posts: 49
  • Gender: Female
  • I've been running forums since 1987 (not a typo!).
    • @lilMMAsweetie on Twitter
    • Snarkish
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #33 on: April 28, 2012, 02:46:37 PM »
Thanks, Fossil. Will do! I'm getting better at bumbling around at a rapid pace!

Binky

Offline psycho180

  • Newbie
  • *
  • Posts: 2
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #34 on: April 30, 2012, 04:24:12 AM »
Is there any mod avlble for this post???

i tried but didn't work check it out plz help me sir...

Offline psycho180

  • Newbie
  • *
  • Posts: 2
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #35 on: April 30, 2012, 05:02:57 AM »
hey thnks man i did... but facing little bit prbm...

adding screenshot help me out plz


Offline BinkyM

  • Semi-Newbie
  • *
  • Posts: 49
  • Gender: Female
  • I've been running forums since 1987 (not a typo!).
    • @lilMMAsweetie on Twitter
    • Snarkish
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #36 on: April 30, 2012, 03:18:00 PM »
Wow, JBlaze; it looks really nice in your screenshot, but all I get it the word "Tweet," and that's it. I'm still on my hunt for Facebook and Twitter buttons!

(Not that my users even *use* these things, but I'm trying to drag us all into the 21st century.) (I only just created a FB page a couple months ago, and it's a fake one. I needed it for some reason or another.) (I haven't anything mundane enough to tweet.)

Binky

Offline Andrew103

  • Newbie
  • *
  • Posts: 1
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #37 on: May 05, 2012, 08:41:40 PM »
Did you have a code for Google +1 ? thanks for code of twitter and facebook it really help to my website what I need is now Google +1 and other coding.




Pools Above Ground

TheListener

  • Guest
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #38 on: May 05, 2012, 08:48:15 PM »
Hi Andrew103

Welcome to smf.

Would THIS help?

Offline cyberhat

  • Semi-Newbie
  • *
  • Posts: 89
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #39 on: May 20, 2012, 09:23:10 AM »
thanks for the share

Offline alchimia

  • Jr. Member
  • **
  • Posts: 125
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #40 on: May 28, 2012, 03:09:09 PM »
Nice tip, but i have one OT question. What's the name of this theme (from screenshot from first post) ?
It's a modified version of Dziner's Inferno theme.
Can we have this modified version?

Offline simon36

  • Jr. Member
  • **
  • Posts: 111
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #41 on: June 06, 2012, 06:01:59 PM »
Does anyone have the code all together to add facebook, twitter and g+1 on to the last post?

Thanks in advance.

Offline 6Scylla

  • Semi-Newbie
  • *
  • Posts: 35
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #42 on: June 07, 2012, 07:03:48 AM »
Awesome trick, Thanks abunch!

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #43 on: June 10, 2012, 01:39:12 AM »
Updated to include Google Plus, as well as neatening up and clarified a few things.
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline graaywolf

  • Semi-Newbie
  • *
  • Posts: 52
  • Gender: Male
  • Webslave!
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #44 on: June 11, 2012, 02:06:07 PM »
J...

GraayWolf here

added your edits and it works fine except the facebook share window is half hidden... you have to guess that what your typing is not a typo lol....

no attachments option I guess so I can't give you a screenshot... come into my stickam chat and i'll show ya what's happening....

I'm trying...

-=(GW)=-

Offline JBlaze

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,156
  • Gender: Male
    • @fragicide on Twitter
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #45 on: June 12, 2012, 09:28:33 AM »
J...

GraayWolf here

added your edits and it works fine except the facebook share window is half hidden... you have to guess that what your typing is not a typo lol....

no attachments option I guess so I can't give you a screenshot... come into my stickam chat and i'll show ya what's happening....

That's because the share window is bigger than the containing div. If it were made any bigger, it would throw off the layout and make things looks like hell. There' no real way to fix it that I can think of.
Jason Clemons
Former Lead Customizer/Support Specialist
Twitter | Facebook | Instagram

Offline kimjhamilton

  • Newbie
  • *
  • Posts: 5
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #46 on: January 15, 2013, 06:34:47 PM »
Don't suppose you have the coding to share to Tumblr as well, cause that would be awesome.

Offline GraphicJunki

  • Semi-Newbie
  • *
  • Posts: 31
    • @Graphicjunki on Twitter
    • GraphicJunki
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #47 on: April 01, 2013, 03:10:20 PM »
This worked for me on most of my themes.  Great tip  thanks. :)

Offline labyo

  • Newbie
  • *
  • Posts: 4
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #48 on: April 07, 2013, 02:19:08 AM »
Thanks  :D

Offline Nickyy

  • Newbie
  • *
  • Posts: 6
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #49 on: November 08, 2013, 05:04:09 AM »
Thank you JBlaze for the tip/trick :)
I have
SMF Package       SMF 1.1.19
Sources                    2.0    1.1.19
Default Templates    2.0    1.1.12
Language Files    2.0    1.1.18
Current Templates    2.0    1.1

The result from adding the code is only a hyperlink to twitter with the word 'Tweet'. Screenshot:


Offline LePhuongBao

  • Semi-Newbie
  • *
  • Posts: 11
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #50 on: December 06, 2013, 01:59:11 AM »
Thank you so much tutorial posts

Offline eric1234

  • Full Member
  • ***
  • Posts: 683
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #51 on: February 26, 2014, 03:37:50 PM »
For some reason it work well in Firefox but in Google Chrome it seem to be malfunction.  :(

Offline Paracelsus

  • Sr. Member
  • ****
  • Posts: 876
  • Gender: Male
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #52 on: March 06, 2015, 09:06:47 AM »
Ok, here's a question: if you want to put a facebook/google+/twitter share link to a POST (not a whole topic or topic page) how to do it?

Offline Paracelsus

  • Sr. Member
  • ****
  • Posts: 876
  • Gender: Male
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #53 on: March 06, 2015, 04:10:23 PM »
Ok, I can answer myself to this one... ;D

In the end I could achieve a working link for each post by using:
Code: [Select]
', $scripturl, '?topic=', $context['current_topic'], '.msg' . $message['id'] . '%23msg' . $message['id'] . '
That code is to be put right after the desired facebook/twitter/google+/etc link, for example:
Code: [Select]
https://www.facebook.com/sharer/sharer.php?u=', $scripturl, '?topic=', $context['current_topic'], '.msg' . $message['id'] . '%23msg' . $message['id'] . '"
You can check it out how it works live here: http://www.forumscp.com/index.php?topic=64983.20 (notice the share icon on top right-corner of each post)

Offline Johnson12

  • Newbie
  • *
  • Posts: 1
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #54 on: April 28, 2015, 08:53:03 PM »
Thank you for your tips adding share button :)

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 900
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #55 on: June 10, 2015, 03:57:44 PM »
Thank you JBlaze for the tip/trick :)
I have
SMF Package       SMF 1.1.19
Sources                    2.0    1.1.19
Default Templates    2.0    1.1.12
Language Files    2.0    1.1.18
Current Templates    2.0    1.1

The result from adding the code is only a hyperlink to twitter with the word 'Tweet'. Screenshot:

Any help on this? I have the same problem. I added this today on the "Flatline" theme. I edited the default "display.template.php" file because my theme doesn't have one. Then I edited my themes "index.template.php" file, as the OP instructs to do so.

The result....Just the text "Tweet", that's it.

Any help is greatly appreciated.

Offline njtweb

  • Sr. Member
  • ****
  • Posts: 900
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #56 on: June 10, 2015, 06:34:41 PM »
Thank you JBlaze for the tip/trick :)
I have
SMF Package       SMF 1.1.19
Sources                    2.0    1.1.19
Default Templates    2.0    1.1.12
Language Files    2.0    1.1.18
Current Templates    2.0    1.1

The result from adding the code is only a hyperlink to twitter with the word 'Tweet'. Screenshot:

Any help on this? I have the same problem. I added this today on the "Flatline" theme. I edited the default "display.template.php" file because my theme doesn't have one. Then I edited my themes "index.template.php" file, as the OP instructs to do so.

The result....Just the text "Tweet", that's it.

Any help is greatly appreciated.

Turns out, my company is blocking twitter and fb. I got home and both show in the post, but no G+

Offline gusu

  • Newbie
  • *
  • Posts: 7
Re: [TIP/TRICK] Adding Twitter and Facebook "Share/Like" Button To Posts
« Reply #57 on: September 30, 2018, 01:58:59 PM »
I'm using the Avada theme. Can I implement this technique safely on it?