Help:Codex_Wiki_Plugins

last edited byusericonadmin on 19-Nov-2008

Contents

Codex Wiki Plugins

Introduction

Codex comes bundled with a set of custom wiki plugins that can be used in any wiki page by following the following syntax:

<nowiki>{{{PluginName arg1="" arg2="" ...}}}</nowiki>

Basically, you create a tag with the name of the plugin to use and then just create arguments of name-value pairs of whatever arguments the plugin's renderit() method takes in.

A Wiki Plugin

Creating wiki plugins are very easy. Just drop them in the /App/plugins/wiki folder and you are ready to start using them in your wiki pages.

A wiki plugin is exactly just like any other ColdBox plugin. ColdBox Plugin Guide.

Rules

  1. Plugin component must extend coldbox.system.plugin and implement the coldbox plugin init() method.
  2. Plugin can just implement the ColdBox init() method with no inheritance, but will not be able to tap into the framework's supertype's methods. It will have to do everything via the injected controller.
  3. Plugin must implement a method called renderit().
    1. This method can have 1 or more arguments.

Example

So if we have a plugin called DateTime, it's source code can look like this:

<cfcomponent name="DateTime" 
			 hint="A datetime wiki plugin" 
			 extends="coldbox.system.plugin" 
			 output="false" 
			 cache="true">
  
<-------------------------------------------- CONSTRUCTOR ------------------------------------------->	
   
    <cffunction name="init" access="public" returntype="DateTime" output="false">
		<cfargument name="controller" type="any" required="true">
		<cfscript>
  		super.Init(arguments.controller);
  		setpluginName("DateTime");
  		setpluginVersion("1.0");
  		setpluginDescription("A date time wiki plugin");
  		//My own Constructor code here
  		
  		//Return instance
  		return this;
		</cfscript>
	</cffunction>

<-------------------------------------------- PUBLIC ------------------------------------------->	

    <---  today --->
	<cffunction name="renderit" output="false" access="public" returntype="string" hint="print today">
		<cfargument name="format" type="string" required="true" default="full" hint="Full,Short, Medium"/>
		<cfreturn dateformat(now(),arguments.format)>
	</cffunction>
	
<-------------------------------------------- PRIVATE ------------------------------------------->	
	
</cfcomponent>

And we can use it in our wiki pages like so:

//Initial space is left so wiki doesn't match and you can see the source
<nowiki>{{{ Messagebox message="Hello World!"}}}</nowiki>

That's it. Welcome to the world of Codex Wiki Plugins. Now go out and start coding your very own plugins. Below you can see a plugin at work:

Installed Plugins

Below is a listing of all installed plugins that can be found in the following directory: /var/www/vhosts/codexplatform.com/httpdocs/plugins/wiki

Download in other Formats:
markup Markup | pdf PDF | swf SWF | html HTML | word Word

comments Comments (0)