jLike Integration Documentation for Developers

Developers who wish to integrate jLike in their own extensions can do so in a very easy way. The following integration guide will help you add jLike (not JomLike) to other extensions in as little as 5 lines of code:). Depending on your situation you might want to use this code either in the core extension views, in a template override or a content or extension specific plugin.

Get the data needed

  1. Complete URL of a resource
  2. Unique Content id: for instance in case of a Joomla article, it should be the id of the article
  3. Element: This is the type of content. You can set this any way you want, but we recommend com_component.view.layout.  For a Joomla article, it would be com_content.article & for a category, it would be com_content.category
  4. Title: The title of the element that will be stored in the database

Use Set Var to Pass the data to jLike

$jinput = JFactory::getApplication()->input;
$jinput->set('data', json_encode(array('cont_id'=>$cont_id, 'element'=>$element, 'title'=>$article->title, 'url'=>$route)));

 Use Set Var to pass the data to jLike.

Show the Like Button

//Require the jlike helper
$jlikehelperObj=new comjlikeHelper();
$likehtml = $jlikehelperObj->showlike();
//return or echo the html depending on where you are using it
return $likehtml;