Creating your own Komento integration is fairly simple. You have to be familiar with PHP and of course the component that you'd like to integrate with.
Let's start creating your first Komento component's plugin. By default, Komento will looks for the component's plugins at /components/com_komento/komento_plugins/. In this folder, you will find all the Komento component's plugins.
- Class Definition
- Mandatory Methods
- Optional Methods
- Trigger Methods
- Sample Class
Creating New Komento Component's Plugin File
Create your own Komento component's plugins in this folder (defined above). Your component's plugins must be named as the same as the component's name for future reference. As example, you have created a Komento component plugin named com_egg as illustrated in the screenshot below.
After you have created the plugin as explained above, you may now start writing your codes. Make sure the class name should always begin with Komento. For instance, Komento must be prepend before your component's name on the class definition: class KomentoComegg.
If your component requires an extra file, you may load it on the constructor method.
Make sure to call parent::__construct($component) at the end of constructor method.
This plugin's class must contains all the following methods. These methods are the Komento core functions required to get all the necessary data.
Function load is essential to Komento in order to load single article to $_item.
Function getContentIds usually used to retrieve all article ids for the specified categories.
Function getCategories is quite an important method in retrieving categories in your component. You need to know whether your component has a single level categories or nested categories which most of Joomla component do have. You have to code this method accordingly.
Function isListingView is a method in which determine whether Komento comment form should not be rendered on this view.
Function isEntryView is the opposite of the above. This method determine whether Komento comment form should be displayed on this view.
Function onExecute is the main method that appends Komento on the article. This method outputs the HTML code upon execution. You may also use it to append code to an article object.
These methods are optional. For some cases, you might need these methods to further manipulate the integration between Komento and your component.
These are advanced methods where you can use them to further extend Komento's feature or usability. Refer to the Trigger documentation for more information.
After you have the integration abstract layer ready and properly in place, you can now call Komento in your template file; on comment section. This to render Komento form.
This method commentify() expects an article object which generated by your component consisting all the necessary properties. It return a html form of Komento to be displayed on the site.
id or $_map['id']- Article ID (This should follow the class method of _map that contains the mapping to the 'id' name).
catid- Category ID that the article belongs to.
introtext- Introtext of the content (typically content before the "Read More" break).
text- Full content of the article.