Simple Machines Community Forum

Customizing SMF => Tips and Tricks => Thema gestartet von: Mick. in Juli 20, 2010, 01:24:31 NACHMITTAGS

Titel: [TIP] Facebook Share Button
Beitrag von: Mick. in Juli 20, 2010, 01:24:31 NACHMITTAGS
Very simple to implement.

Open:
Themes/default/Display.template.php

Find:
// Maybe they want to report this post to the moderator(s)?

Add before:
                      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 />';
                            };
Titel: Re: [TIP] Facebook Share Button
Beitrag von: DoctorMalboro in Juli 20, 2010, 10:04:15 NACHMITTAGS
Both versions?

Wow... i remember that if sentence for my first mod... :P
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Mick. in Juli 20, 2010, 10:44:12 NACHMITTAGS
Zitat von: DoctorMalboro in Juli 20, 2010, 10:04:15 NACHMITTAGS
Both versions?

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

What both versions?  Nevermind.    Yeah, RC3
Titel: Re: [TIP] Facebook Share Button
Beitrag von: rakicko in August 13, 2010, 07:42:05 NACHMITTAGS
where to put share image?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Masterd in August 14, 2010, 02:09:45 NACHMITTAGS
You don't need any image.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: lastnico in August 16, 2010, 10:11:46 VORMITTAG
If you can, try to split up the thing in two parts:

Themes/default/Display.template.php

                      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

              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.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: jekwumoore in August 22, 2010, 12:37:16 NACHMITTAGS
nice job!
Titel: Re: [TIP] Facebook Share Button
Beitrag von: rngrdanny22 in August 30, 2010, 01:13:54 NACHMITTAGS
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!
Titel: Re: [TIP] Facebook Share Button
Beitrag von: lucas-ruroken in August 31, 2010, 12:52:34 NACHMITTAGS
Good tip ;)
Titel: Re: [TIP] Facebook Share Button
Beitrag von: KensonPlays in September 06, 2010, 03:12:28 VORMITTAG
Lastnico's suggestion makes sense...
Titel: Re: [TIP] Facebook Share Button
Beitrag von: L'AltroWeb in September 13, 2010, 09:23:43 VORMITTAG
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)?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Dharshan in September 13, 2010, 09:57:59 VORMITTAG
nice. thanks...
Titel: Re: [TIP] Facebook Share Button
Beitrag von: wcharlot in September 14, 2010, 12:24:41 VORMITTAG
this is really a cool FAcebook share that I can also use.

Thanks  8) 8) 8)
Titel: Re: [TIP] Facebook Share Button
Beitrag von: SEOAUS in September 15, 2010, 01:24:56 VORMITTAG
Good tips thanks for sharing this it will help me a lot. Keep sharing! Thanks!

EDIT: Linked removed
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Herr_Inoddorell in September 23, 2010, 10:28:49 NACHMITTAGS
Zitat von: Dark-Wolf in September 13, 2010, 09:23:43 VORMITTAG
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!
Titel: Re: [TIP] Facebook Share Button
Beitrag von: lucas-ruroken in September 24, 2010, 01:13:31 VORMITTAG
Zitat von: Herr_Inoddorell in September 23, 2010, 10:28:49 NACHMITTAGS
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
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Herr_Inoddorell in September 24, 2010, 05:32:53 NACHMITTAGS
Zitat von: lucas-ruroken in September 24, 2010, 01:13:31 VORMITTAG
Zitat von: Herr_Inoddorell in September 23, 2010, 10:28:49 NACHMITTAGS
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]
Titel: Re: [TIP] Facebook Share Button
Beitrag von: lucas-ruroken in September 25, 2010, 01:50:21 VORMITTAG
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.


Titel: Re: [TIP] Facebook Share Button
Beitrag von: Herr_Inoddorell in September 25, 2010, 07:45:40 VORMITTAG
Zitat von: lucas-ruroken in September 25, 2010, 01:50:21 VORMITTAG
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.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: lucas-ruroken in September 25, 2010, 12:17:09 NACHMITTAGS
of course 8) :P
Titel: Re: [TIP] Facebook Share Button
Beitrag von: searchgr in September 25, 2010, 02:01:52 NACHMITTAGS
Can i add this code to smf 2.0 ?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: lucas-ruroken in September 25, 2010, 06:45:47 NACHMITTAGS
this code is for smf2 ;)
Titel: Re: [TIP] Facebook Share Button
Beitrag von: searchgr in September 26, 2010, 01:34:41 VORMITTAG
sorry, i meant the smf 2 RC2.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: lucas-ruroken in September 26, 2010, 01:53:34 VORMITTAG
Zitat von: searchgr in September 26, 2010, 01:34:41 VORMITTAG
sorry, i meant the smf 2 RC2.

Yeah! It works! ;D
Titel: Re: [TIP] Facebook Share Button
Beitrag von: searchgr in September 27, 2010, 01:45:53 VORMITTAG
Zitat von: lastnico in August 16, 2010, 10:11:46 VORMITTAG
If you can, try to split up the thing in two parts:

Themes/default/Display.template.php

                      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

              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?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: searchgr in September 27, 2010, 01:55:16 VORMITTAG
I have added the code and the facebook shows as a title: An Error Has Occurred!
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Diomet in Oktober 10, 2010, 05:58:59 VORMITTAG
What is the code for "Share" button to appear on every message?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Masterd in November 26, 2010, 01:55:23 NACHMITTAGS
                            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 />';
Titel: Re: [TIP] Facebook Share Button
Beitrag von: kavasa in Mai 09, 2011, 07:03:58 NACHMITTAGS
what about smf1.1.13? :-[
Titel: Re: [TIP] Facebook Share Button
Beitrag von: sunehrigal in Mai 09, 2011, 08:43:06 NACHMITTAGS
Thanks it will really help me to track some traffic from facebook.. Keep sharing such informative and productive stuff.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: metalmaragato in Juli 15, 2011, 01:38:21 VORMITTAG
it work for SMF 1.1.14 and work fine with the Google +1 Topics MOD

Google +1 Topics code

// 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

// 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




Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in Juli 15, 2011, 01:43:39 VORMITTAG
It think it would be a helpful mod for ones who dont like to do manual changes.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: ~Dragon~ in Juli 15, 2011, 07:00:05 VORMITTAG
it is easy tutorial trick! code!

Thank you so much information!
Titel: Re: [TIP] Facebook Share Button
Beitrag von: marci_n in Juli 22, 2011, 05:43:45 NACHMITTAGS
Zitat von: metalmaragato in Juli 15, 2011, 01:38:21 VORMITTAG

This tip with some changes change the button for button_count

// 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?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: 8hoursale in Juli 23, 2011, 06:15:49 NACHMITTAGS
I know this is an old topic, but hopefully someone can help me. I just tired to copy this this code:

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:

// Maybe they want to report this post to the moderator(s)?

received an error that said.

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!
Titel: Re: [TIP] Facebook Share Button
Beitrag von: juliegreen in Juni 30, 2012, 09:00:11 VORMITTAG
is that code working for current smf version? SMF 2.0.2.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Mick. in Juni 30, 2012, 09:28:37 VORMITTAG
Zitat von: juliegreen in Juni 30, 2012, 09:00:11 VORMITTAG
is that code working for current smf version? SMF 2.0.2.
Yes.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: gerzok in Juli 27, 2012, 07:49:54 NACHMITTAGS
this is like the facebook "like" button?  :-\
Titel: Re: [TIP] Facebook Share Button
Beitrag von: goldysaini in August 29, 2012, 01:08:01 VORMITTAG
 this is really a cool Facebook share this it will help me a lot. Keep sharing! Thanks!
Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in August 29, 2012, 01:24:59 VORMITTAG
Zitat von: PLAYBOY in Juli 15, 2011, 01:43:39 VORMITTAG
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?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: adamgilchrist2012 in September 15, 2012, 07:59:59 VORMITTAG
Thanks for the nice tips and I have tried it on my personal web page. It works.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: thexan in September 17, 2012, 12:33:39 VORMITTAG
good job. thank
Titel: Re: [TIP] Facebook Share Button
Beitrag von: wdh280 in September 23, 2012, 02:51:45 VORMITTAG
Zitat von: metalmaragato in Juli 15, 2011, 01:38:21 VORMITTAG
it work for SMF 1.1.14 and work fine with the Google +1 Topics MOD

Google +1 Topics code

// 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

// 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
Titel: Re: [TIP] Facebook Share Button
Beitrag von: siammongkol in Oktober 16, 2012, 04:39:09 NACHMITTAGS
Good Tips
Titel: Re: [TIP] Facebook Share Button
Beitrag von: ViperGoy.CoM in Oktober 30, 2012, 11:50:34 NACHMITTAGS
Let's do it ^^ nice tutorial
Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in November 09, 2012, 07:16:40 VORMITTAG
How can we make it visible only to visitors?
It adds a lot to the load time if added to every post.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: kikwan in November 09, 2012, 09:14:20 VORMITTAG
Very thank ;D
Titel: Re: [TIP] Facebook Share Button
Beitrag von: nualchan in November 11, 2012, 10:17:42 NACHMITTAGS
Nice tutorial thank you kha   ;)
Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in November 12, 2012, 05:23:43 VORMITTAG
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-
Zitat von: marci_n in Juli 22, 2011, 05:43:45 NACHMITTAGS


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

Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in November 19, 2012, 05:31:30 VORMITTAG
Can anybody help me please?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Xhoi in November 20, 2012, 10:32:16 VORMITTAG
ill add this to my plugin im making, hoping ill publish it soon  :-\
Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in November 20, 2012, 12:48:01 NACHMITTAGS
Cool. Please let us know when done.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: rafmak10 in November 24, 2012, 11:42:28 VORMITTAG
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
Titel: Re: [TIP] Facebook Share Button
Beitrag von: Mick. in November 26, 2012, 07:54:42 NACHMITTAGS
Zitat von: PLAYBOY in August 29, 2012, 01:24:59 VORMITTAG
Zitat von: PLAYBOY in Juli 15, 2011, 01:43:39 VORMITTAG
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
Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in November 27, 2012, 01:07:25 VORMITTAG
Zitat von: Mick G. in November 26, 2012, 07:54:42 NACHMITTAGS
Zitat von: PLAYBOY in August 29, 2012, 01:24:59 VORMITTAG
Zitat von: PLAYBOY in Juli 15, 2011, 01:43:39 VORMITTAG
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?
Titel: Re: [TIP] Facebook Share Button
Beitrag von: winsoft in November 28, 2012, 04:21:55 NACHMITTAGS
unfortunately it's not working anymore. Facebook forcing us to use like instead share for some reasons.
Titel: Re: [TIP] Facebook Share Button
Beitrag von: PLAYBOY in November 28, 2012, 04:51:08 NACHMITTAGS
Zitat von: winsoft in November 28, 2012, 04:21:55 NACHMITTAGS
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?