A plugin is an additional piece of software, which extends ImpressPages features. Like a theme defines the look of the website, plugin extends the functionality of the website. Whatever you do, if it is not related to the look of the website, it goes to the plugin. Default installation has Application plugin enabled by default to put your application's logic.

Create your plugin

To create a simple installable plugin, make a new subdirectory in Plugin subdirectory. Then login to administration page, open Plugins panel, and activate by clicking activate button.

Plugin settings

A plugin can have an optional Setup directory containing plugin's setting file called plugin.json. This file must contain meta information about the plugin:

  • title - plugin's title;
  • version - version number that consist of major and minor version numbers separated by dot character;
  • name - unique plugin identifier. Use UpperCamelCase naming. Must match plugin's directory name;
  • description - what the plugin does;
  • author - your personal or company name.

Example Plugin/SamplePlugin/Setup/plugin.json file:

    "title": "My Sample plugin",
    "version": "1.00",
    "name": "SamplePlugin",
    "description": "Just a sample plugin.",
    "author": "CompanyName"

Plugin activation / deactivation / removal

On plugin activation / deactivation and removal, system looks for activate.sql, deactivate.sql, remove.sql files in plugins Plugin/SamplePlugin/Setup/ directory. If these files present, they will be executed on corresponding action. Use them to create or cleanup the required database tables.

But larger plugins may need to do additional operations on activation. Especially on updates. To have full control, create Plugin/SamplePlugin/Setup/Worker class. If the system finds one, it executes respectively activate, deactivate or remove methods.

namespace Plugin\SamplePlugin\Setup;

class Worker

    public function activate()
        //create database table, etc.

    public function deactivate()
        //usually nothing

    public function remove()
        //remove database table, files, etc.

If you release new updated version of your plugin, your activate method has to be smart. As update works in following way:

  • plugin deactivation
  • removal of old files
  • new files upload
  • plugin activation

Your activate method has to understand that it had been installed earlier and run the migrations. 

Do stuff

Please read the following sections that cover most of the things you can do in your plugin:

Plugin asset files

Place any plugin-specific JS, CSS, image and other public files in plugin's assets directory.

Use following function to get a link to file residing in assets directory:

Use ipAddCss and ipAddJs functions to add CSS and JavaScript files to the layout.

See also

comments powered by Disqus