Forums » Customize

Creating Plugins

Vaska A
I WROTE THIS
2007-08-03 16:50:32
 

This is a fast, informal tutorial about creating your own plugins.

PHP is not allowed in the textarea for your exhibits. However, you can create plugins that will process PHP for you.

Plugins

Plugins are stored in this folder: http://your_site.com/ndxz_studio/plugin/

There are two types of plugins:

exhibit.plugin_name.php <= your exhibition formats
plugin.plugin_name.php <= page plugins

We are only concerning ourselves with page plugins here.

Create A Plugin

Create a page plugin and place it in your plugin folder. The name of the plugin is important as it provides the link to your function(s). For instance, a plugin named:

plugin.my_plugin.php

Would be called up in your code as:

From your exhibition textarea. Additionally, you can provide variables as well:

<plug:my_plugin 'string',3,'<%title%>','<%pdate%>' />

'string' represents a value you input yourself.
'3' represents a number or and id (see next).
'%title%' is a system variable. You can access them straight from the database.
(A list is provide below of some common system variables)

Within your plugin page, your function would generically look like this:

function my_plugin ($string, $num, $title, $pdate) { // code goes in here }

Access Objects (Database)

You may access the database from within the plugin as well. I will document this later, but for starters you can access the active objects as:

$OBJ =& get_instance();

The common fetch functions would be:

$result = $OBJ->db->fetchRecord('SELECT...ETC...ETC');
$results = $OBJ->db->fetchArray('SELECT...ETC...ETC');

You can check the /ndxz-studio/db folder for the various database functions.

A Few System Variables

id = page id
title = page title
content = page content
section_id = section id
sec_desc = name of section
pdate = published date (format 0000-00-00 00:00:00)
obj_name = name of site (as set in Settings)

There are alot of undocumented features here...including access to other classes and such. In time, we'll write more documentation for them, but for the time being we are too busy giving support and making improvements to the cms.

Vaska A
I WROTE THIS
2007-08-03 17:19:16
 

I really need to spend some time getting the formatting of text and code nicer in here. Some day. ;)

Showing 1 - 2 of 2 posts in Forum > Customize > Creating Plugins
 

You need to be logged in to post.