How to write a plugin

What is a plugin?

In the frontend a plugin represents funtionalities group by their task. For example there exists a plugin to handle everything related to archives, like showing the content, extract or create an archive.

Structure of a plugin

Each plugin is represented by a folder inside the swfm document tree. This folder has following structure:

  • swfm/plugins/PLUGIN_NAME
    • plugin.js - contains the code of the plugin
    • locale/ - folder that contains files with translated strings

First steps

Here is a very simple example:

(function() {
    //create a new plugin
    SWFM.Plugin.example = {
        //initialize the plugin
        init: function() {
            /*
             * ... your code here ..
             */
        }
    };
    //register the new plugin
    SWFM.PluginManager.register('example', SWFM.Plugin.example);
})();

Naming conventions

The name of the directory of the plugin and the string (first parameter) in SWFM.PluginManager.register have to be identical. This is also the name to load the plugin (see example config).

Inhalt

Vorheriges Thema

Structure

Nächstes Thema

How to write a widget

Diese Seite