Triggers
This is an advanced documentation composed to help site developer customize Komento system.
Due to the nature of Komento's multiple integration capability, triggers in Komento comes in two forms; Component Plugin and Joomla Plugin.
Trigger Settings
Developers may set this trigger by navigating to Components > Komento > Settings > System and locate Trigger Method option. They may choose either Component Plugin or Joomla Plugin.
Component Plugin
Developers can define the required methods in the component integration plugin file. For example, define the following functions in the component integration plugin file to listen and carryout any necessary actions or manipulate the parameters/contents in Komento.
<?php
// Abstract class KomentoExtension can be found at
// `/components/com_komento/komento_plugins/abstract.php`
class KomentoComcontent extends KomentoExtension
{
// This function is called before Komento save comment.
// Caution, some functions requires you to return a boolean
public function onBeforeSaveComment($comment){...}
}
?>
Joomla Plugin
Developers may choose to write a Joomla plugin to listen to the triggered events. This will gives the benefit of packaging and distribution for each plugin individually.
This plugin have to be in the group of Komento by defining it in the plugin's manifest xml file.
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" type="plugin" client="site" group="komento" method="upgrade">
<name>Profiles</name>
<author>Stack Ideas Sdn Bhd</author>
<creationDate>25th April 2016</creationDate>
<copyright>Copyright 2009 - 2017 StackIdeas. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>support@stackideas.com</authorEmail>
<authorUrl>http://www.stackideas.com</authorUrl>
<version>1.0</version>
<description>Description of this plugin</description>
<files>
<filename plugin="profiles">profiles.php</filename>
</files>
</extension>
The function's arguments must always start by Component followed by the Article Id parameters.
<?php
class plgKomentoProfiles extends JPlugin
{
// This function is called before Komento save comment.
// The function's name must be the same and the function's arguments and
// must always start by component followed by the articleId parameters.
// Caution, some functions requires you to return a boolean.
public function onBeforeSaveComment($component, $cid, &$comment){...}
}
?>
Komento's Triggers
Arguments listed below are defined for Component Plugin. To use it in Joomla Plugin, prepend 2 arguments to the original argument as shown in the following example of the same function in Component and Joomla plugin.
<?php
// Component Plugin
public void onBeforeKomentoBar(int &$commentCount){...}
// Joomla Plugin
// Prepend 2 arguments to the original argument; $component and $cid.
public void onBeforeKomentoBar($component, $cid, int &$commentCount){...}
?>
List of Komento's Triggers
<?php
// General trigger function to trigger custom Komento events.
// Some functions requires a return value. Pay attention to the
// return value type as defined before the function name.
void onBeforeKomentoBar(int &$commentCount){...}
void onBeforeKomentoBox(object &$system, object &$comments){...}
bool onBeforeSaveComment(object(&$comment){...}
void onAfterSaveComment(object &$comment){...}
void onBeforeProcessComment(object &$comment){...}
void onAfterProcessComment(object &$comment){...}
bool onBeforeSendNotification(object &$recipient){...}
bool onBeforeDeleteComment(object &$comment){...}
void onAfterDeleteComment(object &$comment){...}
bool onBeforePublishComment(object &$comment){...}
void onAfterPublishComment(object &$comment){...}
bool onBeforeUnpublishComment(object &$comment){...}
void onAfterUnpublishComment(object &$comment){...}
?>
