Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • /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. The example below requires that you place all views (.pdt files) into /plugins/my_plugin/views/default/.

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

 Finally, my_plugin_plugin.php is a special class that must extend the Plugin class of /components/plugins/lib/plugin.php. This class is used for installing, upgrading, uninstalling, and branding the plugin.