Guide: Plugins

tracend edited this page Jun 12, 2012 · 12 revisions

This is a brief introduction how to use and create your own plugins for the CMS

Usage

To use a plugin downloaded from a third party just place the contents in the "app/plugins" folder or your own PLUGINS folder, as defined in index.php.

All plugins need to be placed in their own separate folders. Their existence in the plugins folder automatically makes them installed and active.

If there are any configuration options they will become available in the configuration page of the website administration.

Extend

To extend the website with your own plugins please visit the kisscms-plugins repo which contains examples and walkthroughs how to create your own custom logic...

Plugin folders have the same file structure as the APP folder. Although not all folders may not be required, based on the plugin specs, a plugin folder can contain any of the following:

  • bin: Can contain configuration options in the file config.php
  • controllers: Files that are called from custom URLs (Path in the form: /controller/method/vars)
  • helpers: Classes that add functionality like connecting to SDKs and adding new sections.
  • lib: Where third-party scripts are placed
  • models: New data objects (only available for the plugin)
  • public: Static files that need to be publically available, ex. javascript libraries, image sprites etc.
  • views: Presentation markup for the plugin logic.

Configuration

If the plugin has variables that can be configured (ex. the twitter username for a twitter plugin) you can enter them in the file "bin/config.php" in the following form:

Config::register("main", "site_name", "KISSCMS");

Views in plugins are located in"

plugins/*/views/$filename

Ideally all the jQuery plugins you use would optionally call require() to load them before your code. Most likely jQuery has already been loaded for you by the main foot.php view, but it's always good to make the call every time - RequireJS is intelligent enough to only load the file once.