Pepis CMS Addon Development
A PepisCMS addon is similar to CodeIgniter application component. A common addon consists of:
- Addon main class
- Addon public controller
- Addon admin controller
- Addon models
- Addon views
Addon directory structure
- Addon main class /AddonName/AddonName.php
- Admin controller /AddonName/AddonNameAdminController.php
- Public controller /AddonName/AddonNamePublicController.php
- Addon models /AddonName/model/
- Addon admin views /AddonName/view/admin/
- Addon public views /AddonName/view/public/
Addon main class
Addon main class must have the same name as addon name and must extend the PepisCMSAddon class, example: class NewsletterAddon extends PepisCMSAddon.
PepisCMSAddon is an abstract class implementing PepisCMSAddonInterface.
Any addon must implement the following methods:
- public function getName();
- public function getDisplayName();
- public function getDescription();
Controllers
Addon public controller must extend the controller class and must be named exactly PublicController. The same applies to AdminController.
Views
Addon view is similar to CodeIgniter view, with the difference that it consists only of the code that will be further included in the page frame.
Public view will be included in the presentation part of the page theme.
Addon registration
Addon registration is automatically done by AddonManager. Addon manager registeres addons variables, then calls addon specific procedures encapsulated in the register() method of the addon.
Any addon must implement the register() and unregister() methods of the interface, this methods are called when the addon is registered and unregistered respectively.
Inside the register() method there statements reserving resources (example, creating SQL tables).
The role of the unregister() method is to free previously registered resources: truncate and remove tables, delete cache files, etc.
Addon variables
Addon variables are addon specific variables (settings) managed by a common interface of addon manager.
There are 4 types of addon variables:
- integer
- float
- string
- boolean
Addon variables should be registered in the addon constructor using the method public function registerAddonParameter($parameterName, $parameterType, $parameterIsComulsory = true)
Addon variables are storied in the database and cached cached as local files. Plugin cache is renewed each time a change in configuration occurs.
