Difference between revisions of "OnCommunityStreamRender"

Line 2: Line 2:
 
{{alert|<center>'''Note:''' This article is still work in progress</center>|alert}}
 
{{alert|<center>'''Note:''' This article is still work in progress</center>|alert}}
  
Used in the standard community plugin to gather data for creating activity stream item
+
Used in the standard community plugin to gather data for creating activity stream item<br/>
 
+
More information and full guide can be [[Stream API v2|seen here]]
1) create a standart JomSocial plugin.
+
 
+
2) add onCommunityStreamRender function in the plugin. The function must be public.
+
 
+
3) Arrange the data according to this format:-
+
 
+
 
+
 
+
{
+
 
+
//UserId
+
 
+
"actor":5,
+
 
+
//target id
+
 
+
"target": 6,
+
 
+
"message":"string",
+
 
+
"group" : "JTableGroup object",
+
 
+
"event" : "JTableEvent object",
+
 
+
"headline" : "string",
+
 
+
"location" : "Kuala Lumpur",
+
 
+
"attachments":
+
 
+
[
+
 
+
  {"type":"media"},
+
 
+
  {"type":"video", "id":0, "title":"", "description":"", "duration": "string"},
+
 
+
  {"type":"quote"}
+
 
+
]
+
 
+
 
+
 
+
PHP file of example plugin with code comments and explanations
+
 
+
//refer activities.videos.php file
+
 
+
$stream = new stdClass();
+
 
+
$stream->actor = $user;
+
 
+
$stream->target = null;
+
 
+
$stream->headline = CVideos::getActivityTitleHTML($act);;
+
 
+
$stream->message = "";
+
 
+
$stream->groupid = $act->groupid;
+
 
+
$stream->eventid = $act->eventid;
+
 
+
$stream->attachments = array();
+
 
+
if($act->groupid){
+
 
+
  $group    = JTable::getInstance( 'Group' , 'CTable' );
+
 
+
  $group->load( $act->groupid );
+
 
+
  $stream->group = $group;
+
 
+
}
+
 
+
$attachment = new stdClass();
+
 
+
$attachment->type = 'video';
+
 
+
$attachment->id = $act->cid;
+
 
+
$attachment->title = $video->title;
+
 
+
$attachment->thumbnail = $video->getThumbnail();
+
 
+
$attachment->description = $video->description;
+
 
+
$attachment->duration = CVideosHelper::toNiceHMS(CVideosHelper::formatDuration($video->getDuration()));
+
 
+
$stream->attachments[] = $attachment;
+
 
+
$quoteContent = CActivities::format($act->title);
+
 
+
if(!empty($quoteContent) && $param->get('style') == COMMUNITY_STREAM_STYLE){
+
 
+
  $attachment = new stdClass();
+
 
+
  $attachment->type = 'quote';
+
 
+
  $attachment->message = $quoteContent;
+
 
+
  $stream->attachments[] = $attachment;
+
 
+
}
+
 
+
$this->set('stream', $stream);
+
 
+
$this->load('activities.stream');
+

Revision as of 22:26, 24 April 2013

Since JomSocial 2.8
Note: This article is still work in progress

Used in the standard community plugin to gather data for creating activity stream item
More information and full guide can be seen here