Traq Project Forums

Full Version: Creating Plugins for Traq 2.0
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Creating Plugins for Traq 2.0 is simple, there are two ways you can do it.

The first is the easiest, which is use the AdminCP to create your plugin and hooks then export it to an XML file.

The second is creating your plugin's XML file and entering your data there.

This is the template for an example plugin file:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
    <info>
        <name>Customize Text</name>
        <author>Your Name</author>
        <website>http://yoursite.com</website>
        <version>1.0</version>
    </info>
    <sql>
        <install></install>
        <uninstall></uninstall>
    </sql>
    <hooks>
        <hook title="global.php hook" hook ="global" execorder="1">
            <code><![CDATA[require("inc/myClass.php");]]></code>
        </hook>
        <hook title="formattext() hook" hook="formattext" execorder="1">
            <code>
                <![CDATA[if(!$myClass) $myClass = new myClass;
                $text = $myClass->someFunction($text);]]>
            </code>
        </hook>
    </hooks>
</plugin>

Now the install and uninstall SQL parts are for plugins that need to add stuff to the database or remove stuff from the database when uninstalled.

When using these fields, the SQL should be formatted like so:
Code:
INSERT INTO table (columnOne,columnTwo) VALUES('cool','plugin');
INSERT INTO table2 (columnOne,columnTwo) VALUES('Traq','I love it');
Each query must end with a ; to separate the queries.

Now as you can see from the example plugin, there are two hooks being added, one to the global hook and one to the formattext hook.

The global hook loads at the end of the global file while the formattext hook loads whenever the formattext() function is used.

A list of hooks will be released towards the release of Traq 2.0
Reference URL's