News:

Bored?  Looking to kill some time?  Want to chat with other SMF users?  Join us in IRC chat or Discord

Main Menu

Advance Facebook Like button with OpenGraph (For Each Post)

Started by Ricky., October 15, 2011, 09:50:15 AM

Previous topic - Next topic

glennk

Hi guys, I cant find the settings options ?? Could you please offer some advice


InfoStrides

This mod is good but needs to be improved on. I installed it and it worked very well but interfere with post images. Instead of showing photos in the posts, it showed the inserted pictures on all posts when shared on Facebook.

briggz5d

Like the other poster asked two questions - one being Moving the Like - send buttons UNDER the post content.. that would be the Best place for it..
Thats the only thing stopping me from using this mod..

mithun

Hellooooo..

I have installed and facebook like mod and enabled the settings in miscelleneous but i am unabled to see Likes.

Y? here i am going wrong?

www.technicalmyths.com

Thank you....

With Rgds,
Mithun Jain

Ricky.


ADAMSIFTM

please i need your help what mod do i hv to install to show me fb like bottom on my site im using smf 2.0.2 please help tanx

Ricky.

You can do this with this mod itself , you will have to do some manual changes.  Install this mod and after installation , move some code to bottom :
Code (Find in index.template.php) Select

<fb:like send="false" layout="button_count" width="100" show_faces="false" font=""></fb:like></span>


And remove it, now will show this button in bottom :
Code (Find in index.template.php) Select
<div id="footer_section"><div class="frame">
<ul class="reset">
<li class="copyright">', theme_copyright(), '</li>


Code (After add) Select

' , !empty($modSettings['e_fb_enable']) ? '<li class="copyright"><fb:like send="false" layout="button_count" width="100" show_faces="false" font=""></fb:like>' : '' , '


Remember, this code is not tested but it should give you some idea, it is based upon default curve theme, if you have any other custom theme, you may have to make changes accordingly.

Dan_y2k

Well, I couldn't really understand, and I have a question.

Does this mod allows you to like a specific post inside topics?
On other mods, when I like a specific post, what it shows after I refresh the page is that I like ALL the posts in the topic (and the topic itself).

Frankly, I prefer a simple mod, but to be able to like specific posts in each topic. I figured out that the problem is with the canonical url that SMF 2 outputs.

I'm considering on using your mod, but like I said, I prefer to keep everything simple.
If I knew how to use PHP to change the canonical url of a page in SMF 2 (let's say "$context['current_action'] = 'topic_page'" or something similar), only on specific actions (in my case the topic pages) I would have change it myself...
Regards,
Dan_y2k.

Arantor

The problem isn't entirely down to the canonical URL, it's the fact that Facebook doesn't work on units of 'part of a page', it works for the whole page.

Dan_y2k

Quote from: Arantor on July 09, 2012, 12:06:57 PM
The problem isn't entirely down to the canonical URL, it's the fact that Facebook doesn't work on units of 'part of a page', it works for the whole page.

Well, if it did - I guess the "liking" and "sending" possibilites on a page, were endless. :) But probably would also take more loading time.
Regards,
Dan_y2k.

Arantor

The thing is, a message on its own isn't really often that useful, very often it's only really useful in the context of the stuff around it.

There are like mods that work per-post, just they're not tied to Facebook (which strikes me as a good thing)

Dan_y2k

Hmm, I guess you make a good point.

Although - It would be really nice though, if someone likes a single post, so people (including me) be able to see it's popularity alone, not the as the whole topic.
It can be good if someone likes a post, and when a user click on the link that someone liked, he's being directed directly to that post.
Let's say there's a topic, and in one post, there's an opinion on the whole subject of the topic. If someone likes that post, and a user on facebook will click on it's link, he'll go straight to that opinion.

Like I said, if I knew PHP I would make a change to the index.php?topic=x, and remove the canonical link of it, so the like button will be able to take the link of a single post, OR, I would leave the canonical link, AND make a canonical facebook link, using og:url - that will change on the current message that the user will be on, although my guess it won't work, since the canonical link must be the same.

Well, is there any method I can remove the canonical link only for topic view pages? Something like "$context['current_action'] = 'topic_page'"?
My topic indexing (in Google, etc) isn't important to me that much.

Thanks.
Regards,
Dan_y2k.

Arantor

-sigh- You could remove the canonical link and it wouldn't change a thing, except screwing up all your search engine handling. Facebook still wouldn't work how you want it to work!

Facebook Like does not work on a part-of-page context and removing the canonical URL won't change that.

(And really, do not change the canonical URL in topic pages, because it will seriously penalise you in Google for content duplication)

Dan_y2k

Well, I guess I'll stick to only topic liking... XD

Thanks alot Arantor. I hope to hear good news from you guys soon (you and Nao ;)). Keep up the good work.
Regards,
Dan_y2k.

Arantor

Or, as I already mentioned, you could use a mod that isn't Facebook-driven to indicate likes...

Dan_y2k

Don't think so...

This will require me to use more settings (depends on the mod), hold my fingers crossed that it will get updated when a new version of SMF 2 comes out, make people register (my community is pretty public, so it's not a must-have to register), and probably won't show up the specific posts on Facebook, which what I needed from the start...
Regards,
Dan_y2k.

Arantor


distrue

Having issues getting this to work with custom theme premiummgc

After uploading the package successfully, when you click install all checks are positive, except for the index.template in my custom theme. Of the checks it does, the only one it errors on is :

Fine

// the upshrink image, right-floated


add before

            if(!empty($modSettings['e_fb_enable']) && $context['current_action'] != 'admin'){   
            // Advance FB like with OG
               echo '<span style="float: right; margin-top: 10px;"><div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: \'',(empty($modSettings['e_fb_appId'])?'your app id':$modSettings['e_fb_appId']),'\', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement(\'script\'); e.async = true;
    e.src = document.location.protocol +
      \'//connect.facebook.net/en_US/all.js\'; [nofollow]
    document.getElementById(\'fb-root\').appendChild(e);
  }());
</script>
         <fb:like send="false" layout="button_count" width="100" show_faces="false" font=""></fb:like></span>';
            } // Advance FB like with OG

this theme does not have that section.

After comparing the index.template from this custom theme to the one from default theme, I see that the package is just trying to paste in this code after the:

function template_body_above() , which is is this custom theme index.template file.

I attempted to paste in the above FB code right after function template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;

But no luck. The facebook icons do not show up at all in either the default theme, which had no errors, or the custom theme I was attempting to modify

Any help would be greatly appreciated!

distrue

Update Ricky:

I am attempting to manually modify my index.template of this custom theme. You noted on an earlier post what code needs to be pasted into the header of a custom index.template file, so I did this.

I found:

function template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;
   
   echo'
   

<div id="header"><div class="frame">
      <div id="top_section">
         <h1 class="forumtitle">
            <a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? '<img src="'. $settings['images_url'].'/theme/logo.png" alt="' .$context['forum_name']. '"/>' : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
         </h1>
         <br class="clear"/>
         
         <div class="news normaltext">';

And made it:

function template_body_above()
{
   global $context, $settings, $options, $scripturl, $txt, $modSettings;
   
   echo'
   

<div id="header"><div class="frame">
      <div id="top_section">
         <h1 class="forumtitle">
            <a href="', $scripturl, '">', empty($context['header_logo_url_html_safe']) ? '<img src="'. $settings['images_url'].'/theme/logo.png" alt="' .$context['forum_name']. '"/>' : '<img src="' . $context['header_logo_url_html_safe'] . '" alt="' . $context['forum_name'] . '" />', '</a>
         </h1>
         <br class="clear"/>
         
         <div class="news normaltext">';

            if(!empty($modSettings['e_fb_enable']) && $context['current_action'] != 'admin'){   
            // Advance FB like with OG
               echo '<span style="float: right; margin-top: 10px;"><div id="fb-root"></div>
<script>
  window.fbAsyncInit = function() {
    FB.init({appId: \'',(empty($modSettings['e_fb_appId'])?'your app id':$modSettings['e_fb_appId']),'\', status: true, cookie: true,
             xfbml: true});
  };
  (function() {
    var e = document.createElement(\'script\'); e.async = true;
    e.src = document.location.protocol +
      \'//connect.facebook.net/en_US/all.js\'; [nofollow]
    document.getElementById(\'fb-root\').appendChild(e);
  }());
</script>
         <fb:like send="false" layout="button_count" width="100" show_faces="false" font=""></fb:like></span>';

And now I get a parse error. Any ideas? Could really use help to get this working. thanks

distrue

Error is:

Template Parse Error!
There was a problem loading the /Themes/premiummgc/index.template.php template or language file. Please check the syntax and try again - remember, single quotes (') often have to be escaped with a slash (\). To see more specific error information from PHP, try accessing the file directly.

You may want to try to refresh this page or use the default theme.

Advertisement: