This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal



Sep 23, 2011, 5:26 AM
33 Posts
topic has been resolvedResolved

Facebook Comments | Get current URL

  • Category: Other
  • Platform: All
  • Release: 8.5.2
  • Role:
  • Tags:
  • Replies: 4
 Hi
 
I'm trying to implement facebook comments into a website.  Everything works fine with the following code: 
 
<div id="fb-root"></div>
<script>
         (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0];
  if (d.getElementById(id)) {return;}
  js = d.createElement(s); js.id = id;
  js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
  fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div class="fb-comments" data-href="www.hello.com'" data-num-posts="2" data-width="500"></div>
 
However, I now was to compute the  data-href="www.hello.com'" to be the current URL.
 
I can successfully get the URL using context.getUrl().toString(); but, for the life of me, I cannot get this value to be stored in place of the static address
 
Can someone help me ? 
 
Thanks 
 
 
 
Sep 23, 2011, 7:03 AM
261 Posts
Re: Facebook Comments | Get current URL
Ian,
 
I'm not sure if I understand your problem correctly, but what I think you need to do:
 
- remove the <div class="fb-comments" data-href="www.hello.com'" data-num-posts="2" data-width="500"></div> part from the XPage
- add a computed field control to your xpage, set its output type to HTML and let it compute the entire div, including the dynamic part for the current URL. The formula in the computed field could look like this:
 
"<div class=\"fb-comments\" data-href=\"" + context.getUrl().toString() + "\" data-num-posts=\"2\" data-width=\"500\"></div>"
 
Don't forget to remove the id of the computed field control and to set disableTheme to true: if you don't do that, your div will be wrapped in a span.
 
Mark
Sep 26, 2011, 8:05 AM
33 Posts
Re: Facebook Comments | Get current URL
Hi

Thank you very much for your detailed reply.
 
It solved the problem!!
 
Ian   
Sep 27, 2011, 12:21 PM
33 Posts
Re: Facebook Comments | Get current URL
It solved the problem......    Kind of......
 
Comments box appears perfectly within XPage and comments appear on relevant XPages wall.  However, the link stored in Facebook does not link back to the correct XPage.
 
Here is what is happening:
 
I have a page with a comments box:
 
 
However, when I click the link it Facebook, it returns me to the following address (or somethign similar): 
 
 
My Xpage still loads correctly however, the facebook comments previously submitted do not show.  Is there a way to remove this extra part of the URL?  I don't seem to be able to set an option within the Facebook comments.
 
Thanks for any help or tips you may have! 
 
Ian 
Sep 28, 2011, 8:48 AM
261 Posts
Re: Facebook Comments | Get current URL
Hello Ian,
 
Is the link you mentioned correct (http://www.hello.com/action=openDocument&documentId=12345678)? Shouldn't it contain something like /<db.nsf>/xpage.xsp?action=... ?
 
It might be that the Facebook part that generates the link checks the URL for the existence of a ? character (to see if it already contains querystring parameters). If it doesn't find one, it probably assumes that it needs to insert one for the Facebook. If you do add it, it might be smart enough to add a & instead of a ? which will solve your problem.
 
Mark
 
 

This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal