My company decided to have “like” and “dislike” buttons in our JomSocial for Joomla component in… discussions inside of groups. Why? We renamed “discussions” to “reviews” to allow other users to make reviews of other people stuff they put in groups (pics/videos/music). Now we need “Likes” in it. I will show you how to do that.
First of all – grab a good code editor and a FTP/SFTP client. I do prefer Komodo Edit and Cyberduck (that one’s for Mac; for Windows you may use WinSCP).
When you’re ready open those files from your Joomla directory tree (COM_DIR is the directory of your JomSocial frontend component directory – probably /path/to/joomla/components/com_community):
public function viewdiscussion( )
You should find this line few lines below:
$isBanned = $group->isBanned( $my->id );
$isMember = $group->isMember( $my->id ); CFactory::load( 'libraries' , 'like' ); $likes = new CLike(); $likesHTML = ($isMember && !$isBanned) ? $likes->getHTML( 'groups.viewdiscussion', $topicId, $my->id ) : $likes->getHtmlPublic( 'groups.viewdiscussion', $topicId );
This code will load the CLike JomSocial library (class) and create the proper HTML we will put later in the template. To pass $likesHTML to the template add this at the bottom of this class (you should get the idea where to put it as there are plenty of similar lines in that area):
$tmpl->set( 'likesHTML' , $likesHTML );
Now, go to groups.viewdiscussion.php (mind the lack of “s” on the end of the file; it’s NOT viewdiscussions). Right after:
<!--Discussion : Detail--> <div style="clear: both;"></div>
<div class="vidSubmenu clrfix"> <div id="like-container"><?php echo $likesHTML; ?></div> </div>