You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Plugins are "plug-and-play" applications that extend the functionality of Blesta. This section explains how to design and develop plugins, and highlights the roles plugins may assume when rendering data.

Getting Started with Plugins

Plugins follow the same MVC design pattern that Blesta adheres to. The plugin system in Blesta is provided as a feature of the minPHP. Blesta simply defines the naming convention. For the purpose of this manual, the plugin name we'll refer to is my_plugin. Your plugin name will, of course, differ.

File Structure

Plugins are fully contained within their named plugin directory and placed in the /plugins/ directory. Below is the minimum required file structure for a plugin:

  • /plugins/
    • my_plugin/
      • controllers/
      • models/
      • views/
      • language/
      • my_plugin_controller.php
      • my_plugin_model.php
      • my_plugin_plugin.php

my_plugin_controller.php is the plugin's parent controller. This controller can be used to add supporting methods for the other controllers to inherit. Similarly, my_plugin_model.php is the plugin's parent model and can be used to add supporting methods for the other models to inherit.

Because plugins inherit from the application stack their views default to the view directory defined for application. For this reason, you should always declare the view directory for the views within your plugin.

/plugins/my_plugin/my_plugin_controller.php
<?php
class FeedReaderController extends AppController {
 public function preAction() {
 parent::preAction();
 
 // Override default view directory$this->view->view = "default";
 $this->structure->view = "default";
        //$this->view->setDefaultViewPath("FeedReader");
    }
}
?>

 

 

  • No labels