Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting Facebook comments web plugin

The default sorting order of the facebook comments plugin is by social status. How do I set the default order to reverse chronological on my web page?

I know there is an option on the top of the plugin. But not all users know about it and the sorting order is confusing.

like image 671
Jan Turoň Avatar asked Sep 20 '11 07:09

Jan Turoň


2 Answers

I was googling a lot without success, so I solved this by some reverse engeneering...

  1. Use some browser code inspector to see which iframe was inserted by facebook javascript that adds the comments plugin into the page. Copy the facebook_crazy_url of that iframe (see step 2). The inserted iframe seems to be the only thing that is needed to run the comments properly
  2. Get rid of the FB javascript and insert your own iframe instead: set the url to "https://www.facebook.com/plugins/comments.php?channel_url=facebook_crazy_url&order_by=reverse_time"
like image 63
Jan Turoň Avatar answered Sep 22 '22 05:09

Jan Turoň


Another option inspired by Jan Turoň's solution:

  1. put your fb:comments in a div with id "comments":
    <div id="comments"><fb:comments ...></fb:comments></div>
  1. use jQuery to change the generated iframe's src:
    $('#comments iframe').attr('src', $('#comments iframe').attr('src') + '&order_by=reverse_time')

Of course, you can do this without jQuery.

It loads the comments' frame twice, but it works in all cases without harcoding the iframe's src.

like image 30
Fabrice Avatar answered Sep 22 '22 05:09

Fabrice