Easiest way to add a facebook like button with comments

Started by PLAYBOY, January 03, 2013, 02:46:14 AM

Previous topic - Next topic

PLAYBOY

I have tried
1- All social sharing mods smf has. Some didnt work because outdated and some worked but not quite as i wanted,
2- Checked fb like button codes from fb page and tried to add them. But looks like you have to modify at least 2 php files to get a like button appear under each message. Yet in my case, i couldnt even get that done. There was always some kinda error or blank/white page when i try to put the codes in display.template.php Also facebook button creator asks which link will be shared upon like which means it doesnt just share the current link with the topic etc.
3- I even tried those sharethis.com scripts but they usually require people to register in their system to share and thas just stupid.

Anyways, what i need is a simple "Facebook Like Button" which will share the current link of the topic and when you click like it will open the comment box located right next to the "Report to moderator" in each message.


Can somebody help me please?

PokémonS

きみと手をつなごう つらいときはもっと
ゼロからはじめよう ほら ほら 手をつなごう
みんな手をつなごう つらいときはもっと
力を合わせよう ほら ほら 手をつなごう

PLAYBOY


Colin

I foresee you might have a new years gift coming along rather soon.   ;)
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Colin

PokémonS

Yes, its from my mod, but I havent added the comment box.

So, put this code to Display.template.php

<div id="fb-root"></div><script>(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><div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="true"></div>
きみと手をつなごう つらいときはもっと
ゼロからはじめよう ほら ほら 手をつなごう
みんな手をつなごう つらいときはもっと
力を合わせよう ほら ほら 手をつなごう

PLAYBOY

Quote from: PokémonS on January 03, 2013, 04:12:27 AM
Yes, its from my mod, but I havent added the comment box.

So, put this code to Display.template.php

<div id="fb-root"></div><script>(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><div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="true"></div>

Gives out blank/white page

Quote from: Colin on January 03, 2013, 04:09:27 AM
I foresee you might have a new years gift coming along rather soon.   ;)

Sounds great!
How soon do you think?

PokémonS

Quote from: PLAYBOY on January 03, 2013, 04:23:41 AM
Quote from: PokémonS on January 03, 2013, 04:12:27 AM
Yes, its from my mod, but I havent added the comment box.

So, put this code to Display.template.php

<div id="fb-root"></div><script>(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><div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="true"></div>

Gives out blank/white page

But, it works fine for me D:
I have the Iframe one but it doesnt contain the comment box, it`s not quite as you wanted.
きみと手をつなごう つらいときはもっと
ゼロからはじめよう ほら ほら 手をつなごう
みんな手をつなごう つらいときはもっと
力を合わせよう ほら ほら 手をつなごう

PLAYBOY

Maybe i put the code in a wrong spot. Can you tell me exactly where should i put it in display.template.php?

PokémonS

Okay,

Add this:

echo '
<div id="fb-root"></div><script>(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><div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="true" style="margin-right:20px;padding-bottom:6px;margin-bottom:6px;"></div>';


Before this:


// Are there any custom profile fields for above the signature?
きみと手をつなごう つらいときはもっと
ゼロからはじめよう ほら ほら 手をつなごう
みんな手をつなごう つらいときはもっと
力を合わせよう ほら ほら 手をつなごう

PLAYBOY

Quote from: PokémonS on January 03, 2013, 04:47:59 AM
Okay,

Add this:

echo '
<div id="fb-root"></div><script>(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><div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="true" style="margin-right:20px;padding-bottom:6px;margin-bottom:6px;"></div>';


Before this:


// Are there any custom profile fields for above the signature?


Thas it. Perfect. Thx.

sarhad12

Quote from: PokémonS on January 03, 2013, 04:12:27 AM
Yes, its from my mod, but I havent added the comment box.

So, put this code to Display.template.php

<div id="fb-root"></div><script>(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><div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="true"></div>


Hi im also trying to do this but i cant see display.template.php on any of my themes.

PLAYBOY

Quote from: sarhad12 on January 03, 2013, 03:51:44 PM
Quote from: PokémonS on January 03, 2013, 04:12:27 AM
Yes, its from my mod, but I havent added the comment box.

So, put this code to Display.template.php

<div id="fb-root"></div><script>(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><div class="fb-like" data-send="false" data-layout="button_count" data-width="80" data-show-faces="true"></div>


Hi im also trying to do this but i cant see display.template.php on any of my themes.

then put it in the one in default theme

rodelio.lagahit

there's a "sharethis" mod a revision/update of "addthis" mod. i'm using it and it worked like a charm.


dmask

hi everyone

@PokémonS
i'm using your fb+twitter+g+ mod

thx for adding the comment, was looking for it too :)

just one thing about the twitter button, you have to remove the "via" parameter because on every click on the twitter button it will be linke
Quote<topic object> <topic url> via @PokeStarsIndo
so for every twitter click you will be in the mention of it.
parameter is
data-via="PokeStarsIndo"

i also modified your code and inserted the adsense script so i can have the adsense banner below of the first post of a topic.

find this
// Show Google +1 icon in the first post
if (!empty($modSettings['googleplus_plusone'])) {
echo '
<div class="g-plusone" data-size="medium"></div><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>';
}

echo '
</div>
<br />

add this below
<div style="text-align:center; margin:5px;" >
<div style="margin:auto">
<script type="text/javascript"><!--
google_ad_client = "<<<<< YOUR ADSENSE ID HERE >>>>>";
/* Da post */
google_ad_slot = "<<<< unique slot number >>>>";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</div>
</div>';

attention for the GOOGLE AD CLIENT ad AD SLOT, look the code please.

so thank you PokémonS ;)

Silvershark78

OK Im a little confused, this mod is functional but only with code edits right now correct? When will the mod be released "officiall" Thanks. it sounds great. I have like buttons on the home site but not withing the forum.
Still have lots to learn

PokémonS

@dmask: lol thanks for noticed xD maybe SMF Customizer Team doesnt noticed it Okay now the Tweet button has been fixed, also if you still want disscuss about that mod, please disscuss here: http://www.simplemachines.org/community/index.php?topic=494062

@Silvershark78: Latest version: http://www.simplemachines.org/community/index.php?topic=494062




Also please dont makes any post here.
きみと手をつなごう つらいときはもっと
ゼロからはじめよう ほら ほら 手をつなごう
みんな手をつなごう つらいときはもっと
力を合わせよう ほら ほら 手をつなごう

Advertisement: