Plugin Hooks
The easiest way to understand how the SIMContests plugin system works is look through the files of the SIMContests Core plugin (plg_simcontests_core.zip). After installation, the files are located in /plugins/simcontests/core
.
If you need professional service to help you create your own hook with other 3rd party extensions, please contact us for a free quote.
To create your own plugin that works with SIMContests, first create the manifest XML file:
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.0" method="upgrade" type="plugin" group="simcontests">
<name>Example</name>
<author>John Smith</author>
<creationDate>July 2016</creationDate>
<copyright>Copyright (C) 2016 johnsmith.com</copyright>
<license>GNU General Public License version 2 or later</license>
<authorEmail>This email address is being protected from spambots. You need JavaScript enabled to view it.</authorEmail>
<authorUrl>www.johnsmith.com</authorUrl>
<version>1.0.0</version>
<isapplication>true</isapplication>
<description>This is the description for this plugin</description>
<files>
<filename plugin="example">example.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_simcontests_example.ini</language>
<language tag="en-GB">en-GB.plg_simcontests_example.sys.ini</language>
</languages>
</extension>
Create a example.php
where all the plugin hooks will go in. For example, you can refer to core.php
in the Core plugin. Begin the class declaration with:
<?php defined('_JEXEC') or die('Restricted access'); class plgSIMContestsExample extends JPlugin { protected $autoloadLanguage = true; function __construct(&$subject, $config) { parent::__construct($subject, $config); require_once JPATH_ROOT.'/components/com_simcontests/helpers/core.php'; } } ?>
The hook functions include:
- onNewEntry
-
Function: Triggered right after a new entry is submitted to a contest
Parameters:
$entry_id
- the ID of the submitted ID
$admin_approval
- if true, the entry is submitted by an admin. True only if Admin Approval is enabled, and an admin subsequently approve the submission.To get the entry object:
$entry = SCHelper::getTable('Entries'); $entry->load($entry_id);
- onNewScore
-
Function: Triggered right after a user scores an entry
Parameters:
$score_id
- the ID of the submitted score
$isNew
- true if this is the first time this user scored the entry, false if a previous score exists and the user is changing his scoreTo get the score object:
$score = SCHelper::getTable('Scores'); $score->load($score_id); $points = $score->score;
- onNewComment
-
Function: Triggered right after a comment is submitted
Parameters:
$comment
- the comment object
- onDeleteComment
-
Function: Triggered right after a comment is deleted
Parameters:
$comment
- the comment object
- onNewWinner
-
Function: Triggered right after a an entry wins a contest
Parameters:
$entry_id
- the ID of the winning entry
$position
- the winning position of the entry
$notify_winner
- true if winner is to be notifiedTo get the entry object:
$entry = SCHelper::getTable('Entries'); $entry->load($entry_id);
Product Reviews Rate this product
Guest rated
cool
Posted on 10 November 2017|Was this review helpful to you? Yes No
|