[TIP] Facebook Share Button

Started by Mick., July 20, 2010, 01:24:31 PM

Previous topic - Next topic

Mick.

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 />';
                            };

DoctorMalboro

Both versions?

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

Mick.

Quote from: DoctorMalboro on July 20, 2010, 10:04:15 PM
Both versions?

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

What both versions?  Nevermind.    Yeah, RC3

rakicko


Masterd


lastnico

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.

jekwumoore

we rule the world

rngrdanny22

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!

lucas-ruroken

Adk Portal 3.1 is coming....

Design your universe!

KensonPlays

Lastnico's suggestion makes sense...

Owner of Mesozoic Haven

L'AltroWeb

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)?

Dharshan

R I P  : Steve Jobs | you made the world today look how it is | Thank you

wcharlot

this is really a cool FAcebook share that I can also use.

Thanks  8) 8) 8)

SEOAUS

#13
Good tips thanks for sharing this it will help me a lot. Keep sharing! Thanks!

EDIT: Linked removed

Herr_Inoddorell

Quote from: Dark-Wolf 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)?

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!

lucas-ruroken

Quote from: Herr_Inoddorell on September 23, 2010, 10:28:49 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
Adk Portal 3.1 is coming....

Design your universe!

Herr_Inoddorell

Quote from: lucas-ruroken on September 24, 2010, 01:13:31 AM
Quote from: Herr_Inoddorell on September 23, 2010, 10:28:49 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]

lucas-ruroken

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!

Herr_Inoddorell

Quote from: lucas-ruroken 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.




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.

lucas-ruroken

Adk Portal 3.1 is coming....

Design your universe!

Advertisement: