Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

JoomlaTune Support Forum    JComments component    Integration with third-party extensions    K2 JComments    Topic: K2 v.2.1 full integration with JComments
Pages: 1 [2]   Go Down
  Print  
Author Topic: K2 v.2.1 full integration with JComments  (Read 27370 times)
0 Members and 2 Guests are viewing this topic.
Terp
Newbie
*

Karma: 0
Offline Offline

Posts: 7


« Reply #15 on: November 24, 2009, 03:09:36 »

...found it to be a part of a routine that will attempt to complete some of the fields for registered users, which makes sense why I see the error only when logged in. Wink

Anyway, if anyone else runs into this issue of turning on the k2 anchor text to show the comment count and it firing that error when logged in, you could:


Open up .../components/com_k2/views/item/view.html.php

On or around line 107 find and remove:

Code:
                if (!$user->guest) {
                    $js = "window.addEvent('domready', function(){
$('userName').setProperty('value','".$user->name."');
$('userName').setProperty('disabled','disabled');
$('commentEmail').setProperty('value','".$user->email."');
$('commentEmail').setProperty('disabled','disabled');

})";

                    $document->addScriptDeclaration($js);
                   
                }



[edit] Corrected path...had a lot of files open. Wink
« Last Edit: November 24, 2009, 03:30:32 by Terp » Logged
iMacBoriska
Newbie
*

Karma: 0
Offline Offline

Posts: 1


Email
« Reply #16 on: November 25, 2009, 03:20:15 »

Maybe someone could start the integration description from the start? I done all the instructions, but it seems like it turns Jcomments on everywhere, and I can't turn it off. I just want to turn it on for a few items, replacing the k2 comment system. What could cause such an error?  Huh Huh Huh
Logged
Pepex
Newbie
*

Karma: 0
Offline Offline

Posts: 5


« Reply #17 on: December 02, 2009, 14:12:06 »

 Cheesy
Please, can some one post a clear step to step instructions please. or write a article in : http://www.joomlatune.com/jcomments-integration-guide.html

Thanks.
Logged
Sulpher
Newbie
*

Karma: 3
Offline Offline

Gender: Male
Posts: 21



WWW Email
« Reply #18 on: December 14, 2009, 03:06:10 »

Integration instruction has been updated. (see the first message in this topic)

Tested with next versions:
K2 v 2.1 build 20090909
JComments 2.1.0.8

Anchor works properly when user is logged in. Cheerz.
Logged

csasser
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« Reply #19 on: January 10, 2010, 08:07:15 »

unable to install plug-in com_k2.plugin.zip added to first message since it does not have a xml setup file.   Sad

Logged
teddyfresco
Newbie
*

Karma: 0
Offline Offline

Posts: 7


« Reply #20 on: January 20, 2010, 18:48:20 »

Hi, thank you for your work, but the new 2.2 version has changed some references into the code and now it's difficult to integrate jcomment, would anyone be so kind to update instructions in order to make our favourite comment component workwith k2?
thanks in advance

@csasser: read instructions in first post, you don't have to install the attachment
Logged
BBC
Full Member
***

Karma: 4
Offline Offline

Posts: 212



« Reply #21 on: January 23, 2010, 03:36:31 »

http://community.getk2.org/forum/topics/k2-v21-full-integration-with
Logged
xul
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« Reply #22 on: February 10, 2010, 08:07:09 »

Hi, thank you for your work, but the new 2.2 version has changed some references into the code and now it's difficult to integrate jcomment, would anyone be so kind to update instructions in order to make our favourite comment component workwith k2?

Well im suprised that i made my way into it Smiley. But here it is my implementation of the hack for k2 v2.2 (just an update of the line numbers). Many thanks to all for this (the hack)

1. Open components/com_k2/templates/item.php and remove next code from line 494 up to 571:

Code:

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

  <!-- Item comments -->
  <a name="itemCommentsAnchor" id="itemCommentsAnchor"></a>
 
  <div class="itemComments">
 
  <?php if($this->item->params->get('commentsFormPosition')=='above' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid)))): ?>
  <!-- Item comments form -->
  <div class="itemCommentsForm">
  <?php echo $this->loadTemplate('comments_form'); ?>
  </div>
  <?php endif; ?>

  <?php if($this->item->numOfComments>&& $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2'))): ?>
  <!-- Item user comments -->
  <h3 class="itemCommentsCounter">
  <span><?php echo $this->item->numOfComments?></span> <?php echo ($this->item->numOfComments>1) ? JText::_('comments') : JText::_('comment'); ?>
  </h3>
 
  <ul class="itemCommentsList">
    <?php foreach ($this->item->comments as $key=>$comment): ?>
    <li class="<?php echo ($key%2) ? "odd" "even"?>">
   
    <span class="commentLink">
    <a href="<?php echo $this->item->link?>#comment<?php echo $comment->id?>" name="comment<?php echo $comment->id?>" id="comment<?php echo $comment->id?>">
    <?php echo JText::_('Comment Link'); ?>
    </a>
    </span>
   
<?php if($comment->userImage):?>
<img src="<?php echo $comment->userImage?>" alt="<?php echo $comment->userName?>" width="<?php echo $this->item->params->get('commenterImgWidth'); ?>" />
<?php endif; ?>

<span class="commentDate">
    <?php echo JHTML::_('date'$comment->commentDateJText::_('DATE_FORMAT_LC2')); ?>
    </span>
   
    <span class="commentAuthorName">
    <?php echo JText::_("posted by"); ?>
    <?php if(!empty($comment->userLink)): ?>
    <a href="<?php echo $comment->userLink?>" title="<?php echo $comment->userName?>">
    <?php echo $comment->userName?>
    </a>
    <?php else: ?>
    <?php echo $comment->userName?>
    <?php endif; ?>
    </span>
   
    <p><?php echo $comment->commentText?></p>
   
    <span class="commentAuthorEmail">
    <?php echo JHTML::_('Email.cloak'$comment->commentEmail0); ?>
    </span>
   
<br class="clr" />
    </li>
    <?php endforeach; ?>
  </ul>
 
  <div class="itemCommentsPagination">
  <?php echo $this->pagination->getPagesLinks(); ?>
  <div class="clr"></div>
  </div>
<?php endif; ?>

<?php if($this->item->params->get('commentsFormPosition')=='below' && $this->item->params->get('itemComments') && !JRequest::getInt('print') && ($this->item->params->get('comments') == '1' || ($this->item->params->get('comments') == '2' && K2HelperPermissions::canAddComment($this->item->catid)))): ?>
  <!-- Item comments form -->
  <div class="itemCommentsForm">
  <?php echo $this->loadTemplate('comments_form'); ?>
  </div>
  <?php endif; ?>
 
  </div>
  <?php endif; ?>



And add next code instead of previous one:

Code:

<?php
  defined
'_JEXEC' ) or die( 'Restricted access' );
 
  
$comments JPATH_BASE DS 'components' DS 'com_jcomments' DS 'jcomments.php';
 
  if (
file_exists($comments)) {
    require_once(
$comments);
?>

<a name="itemCommentsAnchor" id="itemCommentsAnchor"></a>
<?php
    
echo JComments::showComments($this->item->id'com_k2'$this->item->title);
  }
?>


2. Open components/com_k2/models/item.php (line 826 up to 834) file and replace:

Code:

function countItemComments($itemID){

$db = & JFactory::getDBO ();
$query="SELECT COUNT(*) FROM #__k2_comments WHERE published=1 AND itemID={$itemID}";
$db->setQuery($query);
$result = $db->loadResult();
return $result;

}

at:

Code:

function countItemComments($itemID){
$comments = JPATH_BASE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';
if (file_exists($comments)) {
require_once($comments);
return JComments::getCommentsCount($itemID, 'com_k2');
}
return 0;
}

Works for me! Cheesy

Logged
smor
Newbie
*

Karma: 0
Offline Offline

Posts: 11


WWW
« Reply #23 on: February 12, 2010, 06:28:18 »

Bellow is a fix for the integration of the K2 authors.php file (modules/mod_k2_tools/tmpl/authors.php) to allow the JComment count to be displayed properly in the box.

The file to be modified is helper.php in modules/mod_k2_tools/helper.php

On line 63-65 comment out or remove this code:
Code:
$query = "SELECT COUNT(*) FROM #__k2_comments WHERE published=1 AND itemID={$author->latest->id}";
$db->setQuery($query);
$author->latest->numOfComments = $db->loadResult();

Replace with this code:
Code:
$comments = JPATH_BASE . DS . 'components' . DS . 'com_jcomments' . DS . 'jcomments.php';
if (file_exists($comments)) {
require_once($comments);
$author->latest->numOfComments = JComments::getCommentsCount($author->latest->id, 'com_k2');
}

You could do this with a function call, however I wasn't able to get it working that way, but this way worked flawlessly for me.

There is no need to modify anything in the author file. It will be properly passed the number of comments.
Logged
kachete
Newbie
*

Karma: 0
Offline Offline

Posts: 2


« Reply #24 on: March 20, 2010, 23:09:21 »

Hi masters

In my case im not an expert in coding but love the component and my site is using K2 so we want to use onle one main comments system in the whole site so we decided to use the best so we choose jcomments

When i try to edit the files you said here in order to achive the hack my code lines you made references are plain intergalactic words so we are trying and cant made it posible no saying the hack dont works, no, only saying that if you can post the files in the regular structuture so we can just upload the files via FTP and all the hacks are just achieved

Are there by any chances the posibility to ensure the modules used in jcomments work fully with K2 it will be a great adition to it.

Please can you for us the non master coding people por a zip file with the regular structure so we can upload the files via FTP

Please

Thanks in advance

Best regards
Logged
TopCop
Newbie
*

Karma: 0
Offline Offline

Posts: 20


Email
« Reply #25 on: March 29, 2010, 17:53:41 »

That would be a very good idea to have some modified files and just upload them via ftp in order to make K2 work together with this comment component.

Could someone who is already running JComments with the latest Version of K2 give us his modified files?

Thanks in advance!

TopCop
Logged
Greyhawk
Newbie
*

Karma: 0
Offline Offline

Posts: 1


« Reply #26 on: May 10, 2010, 14:09:15 »


1. Open components/com_k2/templates/item.php and remove next code from line 494 up to 571: 


Sorry, but in my K2-Install (K2 Version 2.2) there ISN´T a file "item.php" at components/com_k2/templates/.

K2 and his native comments-function works properly, but why does I not have this file in this folder?  Huh

Do you mean components/com_k2/templates/default/item.php ?

Or the "item.php" in one of the other folders (views, models etc.) ?


So I cannot start to try this hack, because I don´t know which "item.php" is to edit. Can anyone help me please?

 Angry







Logged
scyllar
Newbie
*

Karma: 0
Offline Offline

Posts: 7


Email
« Reply #27 on: May 13, 2010, 18:21:16 »

This hack rocks! Thanks so much for this contribution!

I just want to point out that if you don't want to hack the k2 core files too much you don't need to change the second file (components/com_k2/models/item.php). On the item page if you simply want to display the correct comment count then you can still use template overriding. Here goes the instruction:
Open ../templates/YOUR-TEMPLATE-FOLDER/html/com_k2/default/item.php (if you don't have this please refer to k2 template overriding instructions for reference) find this:
Code:
<?php
/**
 * @version $Id: item.php 303 2010-01-07 02:56:33Z joomlaworks $
 * @package K2
 * @author    JoomlaWorks http://www.joomlaworks.gr
 * @copyright Copyright (c) 2006 - 2010 JoomlaWorks Ltd. All rights reserved.
 * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

?>

Add this just after the above:

Code:
<?php 
// start added code for jcomments count
$comments JPATH_BASE DS 'components' DS 'com_jcomments' DS 'jcomments.php';
if (file_exists($comments)) {
include_once($comments);
$this->item->numOfComments JComments::getCommentsCount($this->item->id'com_k2');
}
// end added code for jcomments count
?>


Enjoy! Works for k2 2.2 and Jcomments 2.2
« Last Edit: May 13, 2010, 18:24:21 by scyllar » Logged
Spanners
Newbie
*

Karma: 0
Offline Offline

Posts: 6


« Reply #28 on: July 08, 2010, 07:41:29 »

I think someone may have already posted this, but there's a plugin now for using JComments on K2 items.

http://www.google.com.au/url?sa=t&source=web&cd=4&ved=0CCsQFjAD&url=http%3A%2F%2Fwww.joomlatune.com%2F&ei=qSs1TO2mJ4fBccrr3eYD&usg=AFQjCNGa5Ur9bEgALQ1sZdAgQvOkri1Sew&sig2=l0WJDjrf3P_7PP5ARwMz-g

It also works with the JComments Latest Comments module. All you need to do is go to the JComments module, and in the Module Parameters, change the Source (the 7th option down) to com_k2.

If you're using both K2 items and standard Joomla articles and you want to display latest comments from both types of content, you'll need to make the source com_k2,com_content and make sure there is no space in there, otherwise you'll get nothing.

Hope this helps! A tad easier than all the code in earlier threads!
Logged
Pages: 1 [2]   Go Up
  Print  
JoomlaTune Support Forum    JComments component    Integration with third-party extensions    K2 JComments    Topic: K2 v.2.1 full integration with JComments
 
Jump to: