Implementing CjBlog points system in your component


$api = JPATH_ROOT.'/components/com_cjblog/api.php';
  include_once $api;
  //rest of integration code here

Creating XML rules file

CjBlog points system requires plugin rule file for users to install on their websites and the respective rule should be triggered from your extension. An example rule file looks like below:

<?xml version="1.0" encoding="UTF-8"?>
<extension name="com_communityanswers" type="cjblog_points" method="upgrade">
    <rule_title>New Question</rule_title>
    <rule_description>Points awarded for posting a question.</rule_description>

One rule file may contain as many extension_rule rules as you wish. You can bundle all available point system events in a single file.

Trigger points rule from your extension code

Now inside your component, you may want to trigger the rule by using following code.

$rulename = 'com_communityanswers.newquestion';
$reference = 102; //some unique reference for this rule for example id of your content;
$description = 'some description of awarding this point';
CjBlogApi::award_points($rulename, $userid, 0, $reference, $description);
  • $rulename: name of the rule you defined in extension_rule section of the xml file
  • $userid: to whom this point should be awarded. leave it as 0 to assign to logged in user
  • $reference: unique id of the content for this rule to avoid any duplicate points (optional, default null)
  • $description: some description of this point. for example “Awarded points to view an article A test article”

Developers Video Tutorials

Search the website