Keyword

Let comments in K2 articles show up in JomSocial

  • frold
  • frold's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 7 months ago - 11 years 7 months ago #109999 by frold
Hey,

Im new to K2 and trying to set up K2 for the first time.

I run JomSocial 2.6.2 and when a new comment is added to a K2 article I want it to show up in the activity stream:

File Attachment:


I found this post: getk2.org/community/New-to-K2-Ask-here-first/147628-K2-Add-an-Item-to-Jomsocial-Activity-Stream but it is more then 2 years old and the code is a little messed up.

I manage to make it work with JomSocial 2.6.2

OPEN /www/components/com_k2/models/item.php

FIND
                        if ($params->get('commentsPublishing'))
                        {

ADD AFTER
                        //jomsocial activity stream include                
                        $JSinstallchk = JPATH_BASE . DS . 'components' . DS . 'com_community' . DS . 'libraries' . DS . 'core.php';                                                           
                        //activity stream  - added a comment                
                        if ( file_exists($JSinstallchk)) 
                        {                
                                require_once($JSinstallchk);                
                        }                    
                        $contentTitle = $item->title;                          
                        $link = K2HelperRoute::getItemRoute($item->id.':'.urlencode($item->alias),$item->catid.':'.urlencode($item->category->alias));                    
                        //$item->link=urldecode(JRoute::_($link));                    
                        $item->link=$link;
                                                                                      
                        $act = new stdClass();                                                  
                        $act->cmd    = 'wall.write';                    
                        $act->actor    = $user->id;                    
                        $act->target    = 0; // no target                    
                        $act->title    = JText::_('{actor} added a comment to the article <a href="'.$item->link.'">'.$contentTitle.'</a>');                    
                        $act->content    = '';                    
                        $act->app    = 'wall';                    
                        $act->cid    = 0;
                                         
                        CFactory::load('libraries', 'activities');                    
                        CActivityStream::add($act);

or use this pastebin snippet: pastebin.com/xiWzRkhK

If you need to modify it to your language:

FIND
$act->title    = JText::_('{actor} added a comment to the article <a href="'.$item->link.'">'.$contentTitle.'</a>');

and

REPLACE
added a comment to the article

with your string...

Hope it work for you as well.

You might be want to read this thread to get updates in JomSocial when someone rate an article: getk2.org/community/New-to-K2-Ask-here-first/169385-Let-ratings-of-K2-articles-show-up-in-JomSocial#169385

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

More
11 years 7 months ago #110000 by william white
Replied by william white on topic Re: Let comments in K2 articles show up in JomSocial
Nice work. It would be good if you could override the file/s in question instead of modifying them directly to protect your changes from upgrade.
I have not figured out how to do that yet....

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

  • frold
  • frold's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 7 months ago #110001 by frold
Yeah, that would be the best solution.

Also this solution doesnt support multible language support.

But I dont need that for my site.

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

  • frold
  • frold's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 7 months ago #110002 by frold
To read how to get updates in the activity stream when someone rate an article read: getk2.org/community/New-to-K2-Ask-here-first/169385-Let-ratings-of-K2-articles-show-up-in-JomSocial#169385

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

  • frold
  • frold's Avatar Topic Author
  • Offline
  • Junior Member
More
11 years 7 months ago #110003 by frold
If you want the comment as well to show up

FIND:
                        $act->content    = '';

REPLACE WITH
                        $act->content    = $commentText;   

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

More
11 years 7 months ago #110004 by Adam O.
it's great, but if you want to add comment to this action (comment on K2 article displayed on activity stream) or like this action, it will add, but when you refresh page, in disapear. As I checked, in has no 'contentid' and 'type' in database on table community_wall so comment and like to this activity is saved in database, but it can't be loaded I think

Have you some ideas how to change this (in which file or code lines) to may add comments and 'Likes' to activity e.g. "Richard add a comment to XYZ article"?

good job for this!
best wishes
Adam

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


Powered by Kunena Forum