News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Facebook like inside first post above the body

Started by aw06, January 30, 2011, 10:18:27 PM

Previous topic - Next topic

aw06

Facebook LIKE Button HERE

I'd like to show a Facebook like button in the first post of every topic... basically where i have put in bold above..

I already have the code which i would like to call into my display.template ... Any Ideas ??? I'm trying but it's always breaking the template Need it for SMF 1.1.12

The Facebook Like code
<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like layout="button_count" show_faces="true" width="450"></fb:like>

My Display.Template
// Show the post itself, finally!

echo '

</td>

</tr></table>

<hr width="100%" size="0" style="border-top:1px solid #e1dfe1;" />

<div class="post"', $message['can_modify'] ? ' id="msg_' . $message['id'] . '"' : '', '>', $message['body'], '</div>', $message['can_modify'] ? '

<img src="' . $settings['images_url'] . '/icons/modify_inline.gif" alt="" align="right" id="modify_button_' . $message['id'] . '" style="cursor: pointer;" onclick="modify_msg(\'' . $message['id'] . '\', \'' . $context['session_id'] . '\')" />' : '' , '

</td>

</tr>';



// Now for the attachments, signature, ip logged, etc...


and how i am calling it in .. I have the FB Like code in a php file and i am trying to call it using the code below
//echo
if ($message['id'] == $context['first_message']) include 'fblike.php';
if ($message['id'] == $context['first_message']) echo '<BR>';
if ($message['id'] == $context['first_message']) echo '<BR>';


No matter what i try it breaks the layout or i get errors...
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Mick.

Here you go... use the facebook code
// Show the post itself, finally!
echo '
</td>
</tr></table>
<hr width="100%" size="1" class="hrcolor" />
<div class="post"', $message['can_modify'] ? ' id="msg_' . $message['id'] . '"' : '', '>', $message['body'], '</div>', $message['can_modify'] ? '
<img src="' . $settings['images_url'] . '/icons/modify_inline.gif" alt="" align="right" id="modify_button_' . $message['id'] . '" style="cursor: pointer; display: none;" onclick="modify_msg(\'' . $message['id'] . '\', \'' . $context['session_id'] . '\')" />' : '' , '
</td>
</tr>';



replace with:
// Show the post itself, finally!
echo '
</td>
</tr></table>
<hr width="100%" size="1" class="hrcolor" />
<div class="post"', $message['can_modify'] ? ' id="msg_' . $message['id'] . '"' : '', '>YOU FACEBOOK CODE GOES IN HERE<br>', $message['body'], '</div>', $message['can_modify'] ? '
<img src="' . $settings['images_url'] . '/icons/modify_inline.gif" alt="" align="right" id="modify_button_' . $message['id'] . '" style="cursor: pointer; display: none;" onclick="modify_msg(\'' . $message['id'] . '\', \'' . $context['session_id'] . '\')" />' : '' , '
</td>
</tr>';

aw06

OK, almost got it ... it works ... but it puts the button in  every post ... i just need it in the first post .. not all the replies
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

Do you want to put it on the right side of [This] cat_bar?

aw06

#4
Quote from: Labradoodle-360 on January 31, 2011, 12:21:26 AM
Do you want to put it on the right side of [This] cat_bar?

Naw, would love it right above the message in the first post only :)
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Mick.

Quote from: aw06 on January 30, 2011, 11:47:50 PM
OK, almost got it ... it works ... but it puts the button in  every post ... i just need it in the first post .. not all the replies
I figured that. i was waiting for your reply last night but i fell asleep. lol

try this...


// Show the post itself, finally!
echo '
</td>
</tr></table>
<hr width="100%" size="1" class="hrcolor" />
<div class="post"', $message['can_modify'] ? ' id="msg_' . $message['id'] . '"' : '', '>';if ($message['id'] == $context['topic_first_message']) echo' <script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
                  <fb:like href=', $scripturl, '?topic=', $context['current_topic'], 'layout="standard" width="450" show_faces="true" action="like" colorscheme="light" /></fb:like><br>', $message['body'], '</div>', $message['can_modify'] ? '
<img src="' . $settings['images_url'] . '/icons/modify_inline.gif" alt="" align="right" id="modify_button_' . $message['id'] . '" style="cursor: pointer; display: none;" onclick="modify_msg(\'' . $message['id'] . '\', \'' . $context['session_id'] . '\')" />' : '' , '
</td>
</tr>';



aw06

Works as well .. but now no body is shown in the replies  :-[
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

All Colours Sam

heres another way of doing it:

on your Sources/Display.php  find:

   // Do the censor thang.


and above add:


$facebook_share = 'YOU FACEBOOK CODE GOES IN HERE<br />';

if ($counter == 0)
$message['body'] = ($facebook_share.$message['body']);



by the way this code is from share this topic mod:  http://custom.simplemachines.org/mods/index.php?mod=2111

that mod has the option to show the facebook button only in thefirst message.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

aw06

#8
Not following ...   ::) Can you explain abit more

Blue Devil your FB Like mod looks solid .. is it for 2.0 only ???
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

All Colours Sam

the Display.php  is located in your Sources  folder,  go to that folder with your ftp program, download the file, open the file with your code editor  anf fine this line:

// Do the censor thang.

once you had found that line,   above that line  add the following code:

$facebook_share = 'YOU FACEBOOK CODE GOES IN HERE<br />';
if ($counter == 0)
$message['body'] = ($facebook_share.$message['body']);



and replace YOU FACEBOOK CODE GOES IN HERE   with your actual facebook code, thats all you need to do,  the code will handle the rest.

$counter == 0    makes sure the facebook button only appear in the first message of every topic.


you can do that or you can install the mod wich pretty much take care of all of that plus more options to customize and you got the twitter, buzz and digg buttons as well :)
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

aw06

:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

aw06

#11
OK, seems to be working, but i'm having a problem where if you are logged out of facebook, it does not show the likes ..  :-[
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

Matthew K.

That is probably a problem with Facebook's API then.

Mick.

I'm at work now. Tonight I'll help you with for 1.1.12

My facebook mod shows the likes logged in or not.

aw06

Quote from: Labradoodle-360 on January 31, 2011, 12:33:44 PM
That is probably a problem with Facebook's API then.

I was wondering.. but when i check other sites and on my blog it's ok ...

Quote from: Mick G. on January 31, 2011, 12:37:23 PM
I'm at work now. Tonight I'll help you with for 1.1.12

My facebook mod shows the likes logged in or not.

OK kool ... thank much :)
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

All Colours Sam

#15
whats the code yu're using to show the like button?


edit, its on the first message,   that code needs some edits on your index.template  to  fully  work properly, along with creating a facebook app,  it is better to use the iframe option:

somthing like this:

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

aw06

Quote from: Miss All Sunday on January 31, 2011, 12:52:52 PM
whats the code yu're using to show the like button?

Quote<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script><fb:like layout="button_count" show_faces="false" width="550" action="like" font="verdana"></fb:like>
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

All Colours Sam

yes I did realize while I was posting, I edited my previous message, note that you need to tell facebook the url you want to share.
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

aw06

Quote from: Miss All Sunday on January 31, 2011, 12:52:52 PM
whats the code yu're using to show the like button?


edit, its on the first message,   that code needs some edits on your index.template  to  fully  work properly, along with creating a facebook app,  it is better to use the iframe option:

somthing like this:

<iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fexample.com%2Fpage%2Fto%2Flike&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe>

When i use the iframe code it cannot like each indevidual page,... it just defaults to liking the main domain... and that is shown where ever the like button is...

I created an app .. but i don't see anywhere in the code to put the app ID
:: ShopinJA.com Powered by SMF 1.1.19 | Ig-Oh Theme by Koni | 70 Rock Solid Error Free Mods | Many Custom Edits & Tweaks ::
- Host Unlimited Websites - Free Website Builder & Templates - Unlimited Disk Space & Bandwidth

All Colours Sam

to be able to like an individual topic you need this variable:

$scripturl . '?topic=' . $topic . '.msg' . $message['ID_MSG'] . '#msg' . $message['ID_MSG']

the full code will look like this:

$facebook_url = $scripturl . '?topic=' . $topic . '.msg' . $message['ID_MSG'] . '#msg' . $message['ID_MSG'];
$facebook_share = '<iframe src="http://www.facebook.com/plugins/like.php?href=',$facebook_url,'&amp;layout=standard&amp;show_faces=true&amp;width=450&amp;action=like&amp;colorscheme=light&amp;height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:80px;" allowTransparency="true"></iframe><br />';
if ($counter == 0)
$message['body'] = ($facebook_share.$message['body']);

 
Oh, wouldn't it be great if I *was* crazy? ...then the world would be okay
Suki

Advertisement: