Advertisement:

Author Topic: [TIP] Facebook Share Button  (Read 60953 times)

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,440
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
[TIP] Facebook Share Button
« on: July 20, 2010, 01:24:31 PM »
Very simple to implement.

Open:
Themes/default/Display.template.php

Find:
Code: [Select]
// Maybe they want to report this post to the moderator(s)?
Add before:
Code: [Select]
                      if ($message['id'] == $context['topic_first_message'])
                            echo '<br /><br /><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script><br /><br />';
                            };
« Last Edit: December 04, 2010, 12:39:31 PM by bluedevil »

Offline DoctorMalboro

  • SMF Hero
  • ******
  • Posts: 9,076
  • Gender: Male
  • うまいいいいいい!!!!!
    • @DoctorMalboro on Twitter
    • Personal website
Re: [TIP] Facebook Share Button
« Reply #1 on: July 20, 2010, 10:04:15 PM »
Both versions?

Wow... i remember that if sentence for my first mod... :P

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,440
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: [TIP] Facebook Share Button
« Reply #2 on: July 20, 2010, 10:44:12 PM »
Both versions?

Wow... i remember that if sentence for my first mod... :P

What both versions?  Nevermind.    Yeah, RC3

Offline rakicko

  • Full Member
  • ***
  • Posts: 418
  • Gender: Male
  • Have fun!
    • http://
Re: [TIP] Facebook Share Button
« Reply #3 on: August 13, 2010, 07:42:05 PM »
where to put share image?

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,926
  • Gender: Male
Re: [TIP] Facebook Share Button
« Reply #4 on: August 14, 2010, 02:09:45 PM »
You don't need any image.

Offline lastnico

  • Semi-Newbie
  • *
  • Posts: 45
  • Gender: Male
    • Forum Software Reviews
Re: [TIP] Facebook Share Button
« Reply #5 on: August 16, 2010, 10:11:46 AM »
If you can, try to split up the thing in two parts:

Themes/default/Display.template.php
Code: [Select]
                      if ($message['id'] == $context['first_message']) {
                            echo '<br /><br /><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><br /><br />';
                            };

And put this in the footer
Code: [Select]
              echo '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>';

It will increase page loading speed time (a little bit).

See http://developer.yahoo.com/performance/rules.html#js_bottom for more info.

Offline jekwumoore

  • Semi-Newbie
  • *
  • Posts: 53
Re: [TIP] Facebook Share Button
« Reply #6 on: August 22, 2010, 12:37:16 PM »
nice job!
we rule the world

Offline rngrdanny22

  • Jr. Member
  • **
  • Posts: 214
    • NookForum.com
Re: [TIP] Facebook Share Button
« Reply #7 on: August 30, 2010, 01:13:54 PM »
Great job! I have a quick question... is there anyway to code it to where it only shows on the first message on the first page?

Currently, it is showing on the first message of every page within a topic. I only want it to show on the very first post in the topic.

Thanks!

Offline lucas-ruroken

  • SMF Hero
  • ******
  • Posts: 4,906
  • Gender: Male
  • Adk Developer
    • lucas.ruroken on Facebook
    • lucasruroken on GitHub
Re: [TIP] Facebook Share Button
« Reply #8 on: August 31, 2010, 12:52:34 PM »
Good tip ;)
Adk Portal 3.1 is coming....

Design your universe!

Offline KensonPlays

  • SMF Hero
  • ******
  • Posts: 4,306
    • @Kenson_Plays on Twitter
Re: [TIP] Facebook Share Button
« Reply #9 on: September 06, 2010, 03:12:28 AM »
Lastnico's suggestion makes sense...

Offline L'AltroWeb

  • Jr. Member
  • **
  • Posts: 344
  • Gender: Male
  • L'AltroWeb
    • laltroweb on Facebook
    • @laltroweb on Twitter
    • L'AltroWeb
Re: [TIP] Facebook Share Button
« Reply #10 on: September 13, 2010, 09:23:43 AM »
This code is for every first post in every page.
Is there any way to show only in first topics post (only for page 1)?

Offline Dharshan

  • Full Member
  • ***
  • Posts: 423
  • Gender: Male
  • Free as wind!
    • pcguide
Re: [TIP] Facebook Share Button
« Reply #11 on: September 13, 2010, 09:57:59 AM »
nice. thanks...
R I P  : Steve Jobs | you made the world today look how it is | Thank you

Offline wcharlot

  • Semi-Newbie
  • *
  • Posts: 87
    • Grow Taller
Re: [TIP] Facebook Share Button
« Reply #12 on: September 14, 2010, 12:24:41 AM »
this is really a cool FAcebook share that I can also use.

Thanks  8) 8) 8)

Offline SEOAUS

  • Newbie
  • *
  • Posts: 1
Re: [TIP] Facebook Share Button
« Reply #13 on: September 15, 2010, 01:24:56 AM »
Good tips thanks for sharing this it will help me a lot. Keep sharing! Thanks!

EDIT: Linked removed
« Last Edit: October 01, 2010, 04:15:44 AM by ѕησω »

Offline Herr_Inoddorell

  • Jr. Member
  • **
  • Posts: 311
    • Blind Guardian Argentina
Re: [TIP] Facebook Share Button
« Reply #14 on: September 23, 2010, 10:28:49 PM »
This code is for every first post in every page.
Is there any way to show only in first topics post (only for page 1)?

Use this variable:

if ($message['id'] == $context['topic_first_message'])


BTW, this is for any version. I use it in 1.1.11

Thanks for share!

Offline lucas-ruroken

  • SMF Hero
  • ******
  • Posts: 4,906
  • Gender: Male
  • Adk Developer
    • lucas.ruroken on Facebook
    • lucasruroken on GitHub
Re: [TIP] Facebook Share Button
« Reply #15 on: September 24, 2010, 01:13:31 AM »
Use this variable:

if ($message['id'] == $context['topic_first_message'])


BTW, this is for any version. I use it in 1.1.11

Thanks for share!

Better than that:
global $topicinfo;
if ($message['id'] == $topicinfo['id_first_msg'])

;)


because if you use "if ($message['id'] == $context['topic_first_message']) and you go to the second page... the button appears in the first post of that page :P
Adk Portal 3.1 is coming....

Design your universe!

Offline Herr_Inoddorell

  • Jr. Member
  • **
  • Posts: 311
    • Blind Guardian Argentina
Re: [TIP] Facebook Share Button
« Reply #16 on: September 24, 2010, 05:32:53 PM »
Use this variable:

if ($message['id'] == $context['topic_first_message'])


BTW, this is for any version. I use it in 1.1.11

Thanks for share!

Better than that:
global $topicinfo;
if ($message['id'] == $topicinfo['id_first_msg'])

;)


because if you use "if ($message['id'] == $context['topic_first_message']) and you go to the second page... the button appears in the first post of that page :P

Really? I tested it, but it didn't happen to me, it only shows on the very first message with $context['topic_first_message']).

[spanish mode on]qué raro es hablarte en inglés haha  ;D[/spanish mode off]

Offline lucas-ruroken

  • SMF Hero
  • ******
  • Posts: 4,906
  • Gender: Male
  • Adk Developer
    • lucas.ruroken on Facebook
    • lucasruroken on GitHub
Re: [TIP] Facebook Share Button
« Reply #17 on: September 25, 2010, 01:50:21 AM »
yeah, the english is very hard to me :p

You need add the global $topicinfo.....

$context['topic_first_message']) is for the first message in every page... but $topicinfo['id_first_msg'] is for the first post.


Adk Portal 3.1 is coming....

Design your universe!

Offline Herr_Inoddorell

  • Jr. Member
  • **
  • Posts: 311
    • Blind Guardian Argentina
Re: [TIP] Facebook Share Button
« Reply #18 on: September 25, 2010, 07:45:40 AM »
yeah, the english is very hard to me :p

You need add the global $topicinfo.....

$context['topic_first_message']) is for the first message in every page... but $topicinfo['id_first_msg'] is for the first post.




Fine, but in my case it didn't happen that way, it only shows in the opening post of a topic, instead of the first post of a new page. It works for me at least :P, however, it's good to know another way, so I can learn much more :P.

Offline lucas-ruroken

  • SMF Hero
  • ******
  • Posts: 4,906
  • Gender: Male
  • Adk Developer
    • lucas.ruroken on Facebook
    • lucasruroken on GitHub
Re: [TIP] Facebook Share Button
« Reply #19 on: September 25, 2010, 12:17:09 PM »
of course 8) :P
Adk Portal 3.1 is coming....

Design your universe!

Offline searchgr

  • Sophist Member
  • *****
  • Posts: 1,247
Re: [TIP] Facebook Share Button
« Reply #20 on: September 25, 2010, 02:01:52 PM »
Can i add this code to smf 2.0 ?

Offline lucas-ruroken

  • SMF Hero
  • ******
  • Posts: 4,906
  • Gender: Male
  • Adk Developer
    • lucas.ruroken on Facebook
    • lucasruroken on GitHub
Re: [TIP] Facebook Share Button
« Reply #21 on: September 25, 2010, 06:45:47 PM »
this code is for smf2 ;)
Adk Portal 3.1 is coming....

Design your universe!

Offline searchgr

  • Sophist Member
  • *****
  • Posts: 1,247
Re: [TIP] Facebook Share Button
« Reply #22 on: September 26, 2010, 01:34:41 AM »
sorry, i meant the smf 2 RC2.

Offline lucas-ruroken

  • SMF Hero
  • ******
  • Posts: 4,906
  • Gender: Male
  • Adk Developer
    • lucas.ruroken on Facebook
    • lucasruroken on GitHub
Re: [TIP] Facebook Share Button
« Reply #23 on: September 26, 2010, 01:53:34 AM »
sorry, i meant the smf 2 RC2.

Yeah! It works! ;D
Adk Portal 3.1 is coming....

Design your universe!

Offline searchgr

  • Sophist Member
  • *****
  • Posts: 1,247
Re: [TIP] Facebook Share Button
« Reply #24 on: September 27, 2010, 01:45:53 AM »
If you can, try to split up the thing in two parts:

Themes/default/Display.template.php
Code: [Select]
                      if ($message['id'] == $context['first_message']) {
                            echo '<br /><br /><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><br /><br />';
                            };

And put this in the footer
Code: [Select]
              echo '<script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script>';

It will increase page loading speed time (a little bit).

See http://developer.yahoo.com/performance/rules.html#js_bottom for more info.

Where in the footer? Can you specify please?

Offline searchgr

  • Sophist Member
  • *****
  • Posts: 1,247
Re: [TIP] Facebook Share Button
« Reply #25 on: September 27, 2010, 01:55:16 AM »
I have added the code and the facebook shows as a title: An Error Has Occurred!

Offline Diomet

  • Semi-Newbie
  • *
  • Posts: 19
  • Gender: Male
  • SMF 2.0 RC3
    • FIATFan.ro
Re: [TIP] Facebook Share Button
« Reply #26 on: October 10, 2010, 05:58:59 AM »
What is the code for "Share" button to appear on every message?
SMF 2.0 RC3
My SMF Forum [nofollow]

Offline Masterd

  • SMF Hero
  • ******
  • Posts: 3,926
  • Gender: Male
Re: [TIP] Facebook Share Button
« Reply #27 on: November 26, 2010, 01:55:23 PM »
Code: [Select]
                            echo '<br /><br /><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script><br /><br />';

Offline kavasa

  • Newbie
  • *
  • Posts: 2
Re: [TIP] Facebook Share Button
« Reply #28 on: May 09, 2011, 07:03:58 PM »
what about smf1.1.13? :-[

Offline sunehrigal

  • Newbie
  • *
  • Posts: 5
Re: [TIP] Facebook Share Button
« Reply #29 on: May 09, 2011, 08:43:06 PM »
Thanks it will really help me to track some traffic from facebook.. Keep sharing such informative and productive stuff.

Offline metalmaragato

  • Newbie
  • *
  • Posts: 7
Re: [TIP] Facebook Share Button
« Reply #30 on: July 15, 2011, 01:38:21 AM »
it work for SMF 1.1.14 and work fine with the Google +1 Topics MOD

Google +1 Topics code
Code: [Select]
// Start Google +1 Mod smfhacks.com
if ($message['id'] == $context['topic_first_message'] )
{
echo '<div style="float: left"><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></div>';
}
// End Google Plus +1 Mod smfhacks.com

This tip with some changes change the button for button_count
Code: [Select]
// Start Facebook share
if ($message['id'] == $context['topic_first_message'] )
{
        echo '<div style="float: left"><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>';
                            }
// End Facebook share



« Last Edit: July 15, 2011, 01:48:41 AM by metalmaragato »

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #31 on: July 15, 2011, 01:43:39 AM »
It think it would be a helpful mod for ones who dont like to do manual changes.

Offline ~Dragon~

  • Jr. Member
  • **
  • Posts: 301
  • Gender: Male
Re: [TIP] Facebook Share Button
« Reply #32 on: July 15, 2011, 07:00:05 AM »
it is easy tutorial trick! code!

Thank you so much information!
Please do not PM or email, Thank respond please post fast to SMF!

Offline marci_n

  • Newbie
  • *
  • Posts: 5
Re: [TIP] Facebook Share Button
« Reply #33 on: July 22, 2011, 05:43:45 PM »

This tip with some changes change the button for button_count
Code: [Select]
// Start Facebook share
if ($message['id'] == $context['topic_first_message'] )
{
        echo '<div style="float: left"><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>';
                            }
// End Facebook share






It's working but... when I click on share button facebook doesn't have the forum default thumbnails. Ive got "Choose a thumbnail" on the windows popup and there is forum logo but also avatars from users profile discussing in that shared topics. Any idea?

Offline 8hoursale

  • Newbie
  • *
  • Posts: 3
Re: [TIP] Facebook Share Button
« Reply #34 on: July 23, 2011, 06:15:49 PM »
I know this is an old topic, but hopefully someone can help me. I just tired to copy this this code:

Code: [Select]
if ($message['id'] == $context['topic_first_message'])
                            echo '<br /><br /><a name="fb_share" type="box_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script><br /><br />';};


and put it right before:

Code: [Select]
// Maybe they want to report this post to the moderator(s)?

received an error that said.

Code: [Select]
The file you tried to save generated the following error:
Parse error: syntax error, unexpected '}' in Display.template.php on line 676

I'm using SMF 1.1

I'd appreciate any help.

Thanks!

Offline juliegreen

  • Semi-Newbie
  • *
  • Posts: 62
    • job seekers
Re: [TIP] Facebook Share Button
« Reply #35 on: June 30, 2012, 09:00:11 AM »
is that code working for current smf version? SMF 2.0.2.

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,440
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: [TIP] Facebook Share Button
« Reply #36 on: June 30, 2012, 09:28:37 AM »
is that code working for current smf version? SMF 2.0.2.
Yes.

Offline gerzok

  • Semi-Newbie
  • *
  • Posts: 27
  • Gender: Male
    • @gerzok on Twitter
    • Grupo ClickMedia
Re: [TIP] Facebook Share Button
« Reply #37 on: July 27, 2012, 07:49:54 PM »
this is like the facebook "like" button?  :-\

Offline goldysaini

  • Newbie
  • *
  • Posts: 1
Re: [TIP] Facebook Share Button
« Reply #38 on: August 29, 2012, 01:08:01 AM »
 this is really a cool Facebook share this it will help me a lot. Keep sharing! Thanks!

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #39 on: August 29, 2012, 01:24:59 AM »
It think it would be a helpful mod for ones who dont like to do manual changes.

There is still not a mod to do this right?

Offline adamgilchrist2012

  • Newbie
  • *
  • Posts: 2
Re: [TIP] Facebook Share Button
« Reply #40 on: September 15, 2012, 07:59:59 AM »
Thanks for the nice tips and I have tried it on my personal web page. It works.


Offline wdh280

  • Semi-Newbie
  • *
  • Posts: 23
  • Gender: Male
Re: [TIP] Facebook Share Button
« Reply #42 on: September 23, 2012, 02:51:45 AM »
it work for SMF 1.1.14 and work fine with the Google +1 Topics MOD

Google +1 Topics code
Code: [Select]
// Start Google +1 Mod smfhacks.com
if ($message['id'] == $context['topic_first_message'] )
{
echo '<div style="float: left"><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></div>';
}
// End Google Plus +1 Mod smfhacks.com

This tip with some changes change the button for button_count
Code: [Select]
// Start Facebook share
if ($message['id'] == $context['topic_first_message'] )
{
        echo '<div style="float: left"><a name="fb_share" type="button_count" href="http://www.facebook.com/sharer.php">Share</a><script src="http://static.ak.fbcdn.net/connect.php/js/FB.Share" type="text/javascript"></script></div>';
                            }
// End Facebook share




Doesn't work for me, when i share facebook share button it doesn't pull the thread id. It ends up looking like this www.example.com/forums/index.php/null [nofollow]


Offline ViperGoy.CoM

  • Newbie
  • *
  • Posts: 4
Re: [TIP] Facebook Share Button
« Reply #44 on: October 30, 2012, 11:50:34 PM »
Let's do it ^^ nice tutorial

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #45 on: November 09, 2012, 07:16:40 AM »
How can we make it visible only to visitors?
It adds a lot to the load time if added to every post.

Offline kikwan

  • Semi-Newbie
  • *
  • Posts: 43
  • Gender: Male
Re: [TIP] Facebook Share Button
« Reply #46 on: November 09, 2012, 09:14:20 AM »
Very thank ;D

Offline nualchan

  • Semi-Newbie
  • *
  • Posts: 18
Re: [TIP] Facebook Share Button
« Reply #47 on: November 11, 2012, 10:17:42 PM »
Nice tutorial thank you kha   ;)

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #48 on: November 12, 2012, 05:23:43 AM »
1- How can we make it visible only to visitors?
2- How can we add a logo to the share post? Right now It adds the title and part of the message but there is no logo.
3- Is there anyway to make the count box smaller?
4- How to make this button "Not appear" in some posts/boards ?


5-


How come mine shows a very big count box? How can i remove the count?

« Last Edit: November 19, 2012, 05:25:22 AM by PLAYBOY »

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #49 on: November 19, 2012, 05:31:30 AM »
Can anybody help me please?

Offline Xhoi

  • Newbie
  • *
  • Posts: 4
Re: [TIP] Facebook Share Button
« Reply #50 on: November 20, 2012, 10:32:16 AM »
ill add this to my plugin im making, hoping ill publish it soon  :-\

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #51 on: November 20, 2012, 12:48:01 PM »
Cool. Please let us know when done.

Offline rafmak10

  • Newbie
  • *
  • Posts: 8
Re: [TIP] Facebook Share Button
« Reply #52 on: November 24, 2012, 11:42:28 AM »
Hi,
Do you have any idea ho to change smf code to share topic on facebook not only as a text but text with pictures?
I have thise problem becouse if image is as a attachment I cant share topic with image :(

Best

Offline Mick.

  • Customizer
  • SMF Hero
  • *
  • Posts: 5,440
  • Gender: Male
    • idesignSMF on Facebook
    • @idesign360 on Twitter
    • idesignSMF.com
Re: [TIP] Facebook Share Button
« Reply #53 on: November 26, 2012, 07:54:42 PM »
It think it would be a helpful mod for ones who dont like to do manual changes.

There is still not a mod to do this right?
i think someone made a mod

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #54 on: November 27, 2012, 01:07:25 AM »
It think it would be a helpful mod for ones who dont like to do manual changes.

There is still not a mod to do this right?
i think someone made a mod

Can you give the link or the name of the mod?

Offline winsoft

  • Semi-Newbie
  • *
  • Posts: 54
    • Search UK Jobs
Re: [TIP] Facebook Share Button
« Reply #55 on: November 28, 2012, 04:21:55 PM »
unfortunately it's not working anymore. Facebook forcing us to use like instead share for some reasons.

Offline PLAYBOY

  • SMF Hero
  • ******
  • Posts: 2,074
  • Livephotoshop.com & Lullabyabc.com
    • Lullabies and Us
Re: [TIP] Facebook Share Button
« Reply #56 on: November 28, 2012, 04:51:08 PM »
unfortunately it's not working anymore. Facebook forcing us to use like instead share for some reasons.

It works on my site. FShare is pretty good. But it needs some repair and improvements.


I know there is something like
"Like button but when you click also a comment box popsup so you add a comment there too."
Can we make this current like button like that?