Jump to content


Click here to lend your support to: Traq and make a donation at pledgie.com !
Photo

Creating Plugins for Traq 2.0


  • Please log in to reply
No replies to this topic

#1 Jack

Jack

    Project Founder

  • Administrators
  • 673 posts
  • LocationAustralia

Posted 05 January 2010 - 05:50 PM

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:
<?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:
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


0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users