Facebook Comments

6 posts by 3 authors in: Forums > CMS Builder
Last Post: June 20, 2013   (RSS)

Hi all,

Right now my actual blog (facebook comments) is not recognizing each post as it's own page.  So when I click on the first post for ex. and write testing 123 etc., that same comment will show up for every post.  ex. I go to the details page on the next post, and the same comments are there from other pages.  I went in and changed the FB code, but still no change.  It's not much of a blog if the comments are not specific to each article.  I've used FB comments on other websites with CMS Builder and have not had this problem.  Any thoughts on what the issue might be? 

Thanks,

ko19

By Jason - June 18, 2013

Hi,

Would you be able to post the code you are using for comments on your detail pages?  Facebook comments are a 3rd Party script, but I can take a look and let you know if I see any issues.

Hope this helps

---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By gregThomas - June 19, 2013

Hi,

I think the problem might be that your div for the Facebook comments doesn't contain the URL for the current page in the data-href, it needs to contain the full URL of the current page. You could find the current full URL using these functions:

function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); }

function selfURL() { 
    $s = empty($_SERVER["HTTPS"]) ? '' : ($_SERVER["HTTPS"] == "on") ? "s" : ""; 
    $protocol = strleft(strtolower($_SERVER["SERVER_PROTOCOL"]), "/").$s; 
    $port = ($_SERVER["SERVER_PORT"] == "80") ? "" : (":".$_SERVER["SERVER_PORT"]); 
    return $protocol."://".$_SERVER['SERVER_NAME'].$port.$_SERVER['REQUEST_URI']; 

Then on the div with the class fb-comments you need to amend data-href tag to contain the current page URL:

<div class="fb-comments" data-href="<?php echo selfURL(); ?>" data-width="745" data-num-posts="10"></div>

Let me know if you have any questions.

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

By gregThomas - June 19, 2013

I've just found out there is a function built into CMS Builder that will return the current pages full URL which you could instead. Then you would only need to modify the facebook comments line to look like this:

<div class="fb-comments" data-href="<?php echo thisPageUrl(); ?>" data-width="745" data-num-posts="10"></div>

Thanks!

Greg

Greg Thomas







PHP Programmer - interactivetools.com

super...this is what I was looking for :)  Thanks Greg, much appreciated.