[TOC]

Modifying Ninja's behavior

Using addons

Addons are small pieces of "drop-in" code that customizes the Ninja GUI without having to edit the source files directly. By dropping your own directory with a PHP file that does something nifty, you can add (or remove) page elements. Addons are located in /opt/monitor/op5/ninja/application/addons.*

Example: Let's say that you would like to add a link to your intranet that should be located in the top bar just below the Ninja logo. We start by creating the directory 'intranet_link' which contains a PHP file named link.php and a javascript file called link.js.

in link.php:

$this->xtra_js[] = 'application/addons/intranet_link/link.js';

in link.js:

$(document).ready(function() {
        $('#quicklinks')
                .append('<ul><li><a href="/path/to/intranet">Intranet</a></li></ul>');
});

This will make the link.js file to be included in the document header and create a link that will point to your intranet.

Add a new menu item

Copy any file in the folder application/addons/menu to your_menu_item.php. Modify the contents (especially the URI) to suit your needs.

Creating your own widgets

See the documentation section on Widgets.

Finetuning Ninja, editing existing code

There is a "Hello World" bundle located in ninja/xdoc/demo_module_hello_world. Read through the controller-file to grasp how you can add any code you would like to your Ninja installation.

Coding with Ninja is to a high degree, interacting with the php framework Kohana 2. You can modify Ninja's behaviour in several different layers. Before you do that, remember that the files to look for are in /opt/monitor/op5/ninja on your Monitor server (or better yet, a test server).

To reuse built-in features, read the detailed method documentation of Data Structures, in particular, look for classes with names ending in _Model. These will give you the data you need to use for the next step: coding your own solutions with Ninja as a tool to build on.

Ninja is open source

Instead of keeping your changes to yourself, send an email (preferrably with a patch) to op5-users@lists.op5.com. If you solved a bug or came up with an idea that's good & general enough to incorporate into Ninja itself, besides making the world better; you will be mentioned in op5's bug tracker, git revision history, release notes and probably get points on Ohloh and the likes, as well.

 All Data Structures Functions Variables

Generated on 4 Apr 2014 for ninja by  doxygen 1.6.1