Let’s continue with our sample plugin “PreviewPlugin”. If you look inside its root folder (/protected/plugins/PreviewPlugin), you’ll see the following structure (NOTE: plugin folder name has to end with “Plugin”: PreviewPlugin, DemoPlugin, MyTestPlugin, etc.):

  • CSS --> main CSS
  • JS --> main JS
  • settings --> config.json --> form.json
  • views --> button_inline.php --> button_separate.php --> standalone.php
  • PreviewPlugin.php

CSS folder contains any css files, required by the plugin (NOTE: Elegant 6 connects plugin’s css files automatically in alphabetical order; simply put a file into this folder and it will be loaded with the plugin )

JS folder contains any js files, required by the plugin (NOTE: Elegant 6 connects plugin’s js files automatically in alphabetical order; simply put a file into this folder and it will be loaded with the plugin )

settings folder contains two main plugin configuration files. Both files must have valid json formatting and a set of required options.

config.json:

Virtual host configuring, img #01.1

Available config.json options:

title Plugin title. Can be any value, name it something intuitive.
version Plugin version. Helps users to understand which plugin version they currently have
description Custom plugin description. May include any info you find necessary.
actions json array, that holds Elegant 6 actions names. The plugin will only be available for actions, listed here. The full actions array would look like this:
Virtual host configuring, img #01.1

form.json:

Virtual host configuring, img #01.1

form.json contains plugin settings form, displayed in to “Admin”-> “Sites”-> “Some site”-> “Plugins” tab.

Virtual host configuring, img #01.1

In the picture you can see three options formatted according to Elegant 6 API requirements (see plugin options for more info). These options values will be available inside plugin using “getSetting” method (see plugin methods for more info).

Each Elegant 6 site can have its own plugin configuration.

“views” folder contains view templates that you may utilize for various plugin needs.

  • Template may have any title you find suitable
  • Template is attached and displayed using YII API (see yii documentation for more info).
  • Template may be a php file with .php extension or SMARTY template file with .html extension. (see Smarty documentation for more info)

“PreviewPlugin.php” file contains main plugin class.

  • Main plugin file has to have the same name as plugin folder,
  • Plugin class, described inside this file has to have the same name as plugin file
  • Plugin class, described inside this file has to extend CPlugin Elegant 6 API class