Luca

[Solved 19r] Facebook Comment and K2 Comment Box Together

20 posts in this topic

Hi all,

I would like to know if is possibile display both Facebook Comment and K2 Comment Box together. On my website many user doesn't prefer to comment with Facebook (even if i like this last solution!!!!).

If I set in the plugin "Before Comment Block (K2)" and I check on the items, its shown two Facebook Comments!!!

It seems like if the Facebook Comment overwrote the K2 Comment Box!

Do you have any suggest?

Thanks in advance!

Share this post


Link to post
Share on other sites

Hi guys

I'm sorry. There is no way unless change code of K2.

To display FB comment we must override K2 function that is show K2 comment form.

K2 team also notice it in their source code.

If you really want to display both of them maybe you should ask K2 team for solution.

Sorry again.

Share this post


Link to post
Share on other sites

Hi again.

Our developer just found out problem. We must change hard code of K2 component a little.

1. To solve problem 2 FB comment. Please open file /plugins/content/bt_socialshare/bt_socialshare.php

Find this line

$addedhtml = '<div class="bt-social-share bt-social-share-after-title">' .$this->getPretext(). $this->html . $this->fbComment;

Change it to

$addedhtml = '<div class="bt-social-share bt-social-share-after-title">' .$this->getPretext(). $this->html;

2. Open file /components/com_k2/view/item/view.html.php

Find this line

if (empty($item->event->K2CommentsCounter) && empty($item->event->K2CommentsBlock))

Change to

if (true)

3. Openf file /components/com_k2/templates/default/item.php

Find this line

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

Change it to

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

Enjoy it

Share this post


Link to post
Share on other sites

Hi all,

I'll be back just to ask something more about the request I did before...

With this trick both comment (Facebook and K2) modules are visibile, but only if the user is already logged into the site (I don't want that everyone post comment so I have enabled comment only for registered users)....

So what I would like to reach is:

Anonymous user can comment with Facebook or some other social network (Facebook is enought anyway)...

Only registered and logged users can use the K2 comment form.

Do you think is possible?

Sorry but I haven't the know how to solve this other issue!!!!!

Share this post


Link to post
Share on other sites

Hi

Please use this solution.

Open file plugins/content/bt_socialshare/bt_socialshare.php

Find these line

if($params->get('comments')){
$addedhtml .= $this->fbComment;
}

Change it to

$user = JFactory::get('user');
if(!$user->get('guest') && $params->get('comments')){
$addedhtml .= $this->fbComment;
}

Only logged user can use FB comment

Share this post


Link to post
Share on other sites

Hi all,

first of all, sorry for delay in answer but only today I found time to worl at my website...

Tronghm, thanks for your effort but solution you gave me is not working.

When I change the file you told me, I got an erron when I click on "read more" button; the error sounds like:

Fatal error: Call to undefined method JFactory::get() in /web/htdocs/www.marsicacalcio5.it/home/plugins/content/bt_socialshare/bt_socialshare.php on line 294

At row 294 I have this line of code:

$user = JFactory::get('user');

so what I tried to do, using my best friend Google, is changing the line to

$user = JFactory::getUser('user');

and after that I didn't get the error anymore, but nothing changed in comments issue...

Sorry but I'm not so able with php language!

So do you have other suggestions to test?

Just to remind... I would like to have this behaviour: logged users can post comment with K2 Comments and Facebokk plug in; not logged users can publish comments through Facebook plug in.

Thanks in advance!

Share this post


Link to post
Share on other sites

OK, now I don't get the error... But problem about comments has not been solved.

Do I have to change the condition inside the

if(!$user->get('guest') && $params->get('comments'))

Maybe guest is for English Language (my site is in italian)... I don't belive so...

Anyway this code doesn't solve my question... (even if I use ! - negative - or not)

Facebbok Comments are shown only when a user is logged in; I would like to have FB Comments for all visitors, registered and not registered.

Thanks again for your effort

Share this post


Link to post
Share on other sites

Maybe, i misunderstand your require.

So please try to find this code in the file

if(!$k2){

$this->extra .= $this->fbComment;

}

Change to

$this->extra .= $this->fbComment;

And remove the code in above reply.

Good luck

Share this post


Link to post
Share on other sites

That's fantastic!!!!!

Now it works as I like...

In addition I have commented also the code below

if($params->get('comments')){

$addedhtml .= $this->fbComment;

}

in order to avoid double Facebook Comment Window when a user is logged in...

Thank you very much for your great support!

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now