Keyword

RE: K2 Facebook Comment Box

  • Elmer Balbin
  • Elmer Balbin's Avatar Topic Author
  • Offline
  • New Member
More
11 years 3 months ago - 11 years 3 months ago #114521 by Elmer Balbin
RE: K2 Facebook Comment Box was created by Elmer Balbin
Greetings K2,

I have recently went around the community forums and found a solution to my problem regarding how to implement the Facebook comment box replacing the standard K2 comment box of items.

Now my only problem is on how to display the comments of PER item. What I mean is to display comments only for the specific item and not all comments from a single site. Below is the attached code. If I understand the code correctly, it only displays the comments from the 'data-href'. In this case, www.example.com/blog/item-1.

How can I make comments for each item since this is a global overide of all the Items? Any help would be appreciated!



<?php if($this->item->params->get('itemComments') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2')) && empty($this->item->event->K2CommentsBlock)): ?>

<!-- Item comments -->

<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.example.com/blog/item-1" data-width="500" data-num-posts="10">


<?php endif; ?>

Please Log in or Create an account to join the conversation.

  • Elmer Balbin
  • Elmer Balbin's Avatar Topic Author
  • Offline
  • New Member
More
11 years 3 months ago #114522 by Elmer Balbin
Replied by Elmer Balbin on topic Re: RE: K2 Facebook Comment Box
Nevermind, I got it! :D For those who are looking for the same thing here's what I done. I simply changed the value of data-href to a php function that retrieves the current address.

Here is the updated code:


<?php if($this->item->params->get('itemComments') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2')) && empty($this->item->event->K2CommentsBlock)): ?>

<!-- Item comments -->

<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="<?php $url="http://".$_SERVER.$_SERVER; echo $url; ?>" data-width="500" data-num-posts="10"></div>

<?php endif; ?>

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 months ago #114523 by Krikor Boghossian
Replied by Krikor Boghossian on topic [SOLVED] RE: K2 Facebook Comment Box
Hello Elmer,

That will work but you can always try $this->item->absoluteURL; instead of $_SERVER.$_SERVER; echo $url.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
11 years 3 months ago #114524 by Stonedfury
Replied by Stonedfury on topic Re: [SOLVED] RE: K2 Facebook Comment Box
Is this on the item view page? I am looking for the same thing. :)

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 months ago #114525 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: RE: K2 Facebook Comment Box
Yes. in item.php

For more information on overriding please read this tutorial getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

and be sure to watch these videos getk2.org/documentation/k2class2012

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
11 years 3 months ago #114526 by Christian Matthew
Replied by Christian Matthew on topic Re: RE: K2 Facebook Comment Box
guys can you comment on this a little more as I have no idea how to do this or where you got your information from?

thanks

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
11 years 3 months ago #114527 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: RE: K2 Facebook Comment Box
Hello Christian

The url where you can generate the facebook comments code is developers.facebook.com/docs/reference/plugins/comments/

Remember to fill in the data-href="" attribute with the <?php echo $this->item->absoluteURL; ?> variable.

You also need to read this mini tutorial on overriding on order to understand which file you need to edit.
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
11 years 2 months ago #114528 by Christian Matthew
Replied by Christian Matthew on topic Re: RE: K2 Facebook Comment Box
i went with jfbconnect which adds the functionality if I need but moreover i went with discuss because it is better IMHO and uses facebook login if the user wants.

Please Log in or Create an account to join the conversation.

More
10 years 2 months ago - 10 years 2 months ago #114529 by Shiv240
Replied by Shiv240 on topic Re: RE: K2 Facebook Comment Box
Genius Elmer Balbin !
But i didn't get what is absolute url.
$this->item->absoluteURL??

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
10 years 2 months ago #114530 by Krikor Boghossian
Replied by Krikor Boghossian on topic Re: RE: K2 Facebook Comment Box
The item's absolute url which is needed for the comments to work properly.
The regular one is relative to the site and will not work properly.

Absolute urls start with www.example.com/....

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum