Joomla Plugin Events

JReviews triggers a number of native Joomla plugin events before and after certain actions.

Overview

If you need to build and ship a native Joomla plugin with your extension, or prefer this method over the developer events, you can find the list of native events available below.

There are events for the content group, which allow integrating with native content events. And there are also events in the custom jreviews group.

These native events behave just like action hooks which receive data, perform tasks, and return nothing.

Development & Support
Customizations are not included with support. We provide this information to make it easier for developers to extend the functionality. From time to time we may have some availability for custom work. Get in touch to see if there's an opportunity to work together.

Content Events

  • onContentBeforeSave
  • onContentAfterSave
  • onContentChangeState

JReviews Events

  • onBeforeReviewCommentDelete
  • onAfterReviewCommentCreate
  • onAfterFavoriteAdd
  • onAfterFavoriteRemove
  • onBeforeListingDelete
  • onAfterListingCreate
  • onAfterListingUpdate
  • onAfterMediaLikeYes
  • onAfterMediaLikeNo
  • onAfterMediaUpload
  • onBeforeReviewDelete
  • onAfterReviewCreate
  • onAfterReviewVoteYes
  • onAfterReviewVoteNo

The event class method receives an argument that is an array with useful info related to the object. A simple JReviews Joomla plugin that performs an action after a listing is added to favorites would look like this:

class plgJreviewsExample extends JPlugin { 

   /**
    * After listing added to favorites 	 
    * @param  array $data   array('listing_id','listing','url') 	 
   */     
   function onAfterFavoriteAdd($data) 
   {
      // Your code here
   } 
}

Boilerplate Plugin

Below you can find a boilerplate plugin example with XML and PHP files.

<?xml version="1.0" encoding="utf-8"?>
<extension version="3.9" type="plugin" group="jreviews" method="upgrade" client="site">
    <name>JReviews - Example</name>
    <version>1.0</version>
    <creationDate>July 2020</creationDate>
    <author>ClickFWD</author>
    <authorEmail>[email protected]</authorEmail>
    <authorUrl>https://www.jreviews.com</authorUrl>
    <copyright>Copyright (C) 2010-2020 ClickFWD. All rights reserved.</copyright>
    <license>http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
    <description>JReviews Example Plugin</description>
    <files>
        <filename plugin="example">example.php</filename>
    </files>
</extension>
<?php
defined('_JEXEC') or die('Restricted access');

class plgJreviewsExample extends JPlugin
{
	/**
	 * Before review comment is deleted
	 * @param  [type] $data [description]
	 * @return [type]       [description]
	 */
	function onBeforeReviewCommentDelete($data) {}

	/**
	 * After new review comment is submitted. Also runs after approval of moderated submissions.
	 * @param  [type] $data array('discussion_id','url','listing_url','discussion','listing')
	 * @return [type]       [description]
	 */
	function onAfterReviewCommentCreate($data) {}
	/**
	 * After listing added to favorites
	 * @param  array $data   array('listing_id','listing','url')
	 * @return [type]       [description]
	 */
    function onAfterFavoriteAdd($data) {}

    /**
     * After listing removed from favorites
	 * @param  array $data   array('listing_id','listing','url')
     * @return [type]       [description]
     */
    function onAfterFavoriteRemove($data) {}

    /**
     * Before listing is deleted
     * @param  array $data   array('listing_id','listing')
     * @return [type]       [description]
     */
    function onBeforeListingDelete($data) {}

    /**
     * After new listing is submitted and published. Also runs after approval of moderated submissions.
     * @param  [type] $data   array('listing_id','url','listing')
     * @return [type]       [description]
     */
    function onAfterListingCreate($data) {}

    /**
     * After media is liked
     * @param  [type] $data   array('media_id','media_type','url','listing_url','media','listing')
     * @return [type]       [description]
     */
    function onAfterMediaLikeYes($data) {}

    /**
     * After media is not liked
     * @param  [type] $data   array('media_id','media_type','url','listing_url','media','listing')
     * @return [type]       [description]
     */
    function onAfterMediaLikeNo($data) {}

    /**
     * After media upload. Also runs after approval of moderated submissions.
     * @param  [type] $data   array('media_id','media_type','url','listing_url','media','listing')
     * @return [type]       [description]
     */
    function onAfterMediaUpload($data) {}

    /**
     * Before review is deleted
     * @param  [type] $data   array('review_id','review')
     * @return [type]       [description]
     */
    function onBeforeReviewDelete($data) {}

    /**
     * After new review is submitted. Also runs after approval of moderated submissions.
     * @param  [type] $data   array('review_id','url','review')
     * @return [type]       [description]
     */
    function onAfterReviewCreate($data) {}

    /**
     * After review is found helpful
     * @param  [type] $data   array('review_id','url','listing_url','review','listing')
     * @return [type]       [description]
     */
    function onAfterReviewVoteYes($data) {}

    /**
     * After review is found not helpful
     * @param  [type] $data   array('review_id','url','listing_url','review','listing')
     * @return [type]       [description]
     */
    function onAfterReviewVoteNo($data) {}
}