FIXME

Extract from PhpNut’s announcement of RC4:

Plugins are mini apps that have controllers, models, and views. The plugins can have their own AppController and AppModel, but they must be prefixed with the plugin name. So, lets say we have a blog with a custom AppController and AppModel. The name of my blog plugin happens to be CakeBlog. So, I have a cake_blog_app_controller.php and a cake_blog_app_model.php, inside of the cake_blog directory which I place in /app/plugins. I set the “prefix” in app/config/database.php to use cake_blog and created the plugins tables. Then I goto http://example.com/cake_blog/ and voila a working blog. To make your app work as a plugin you need to make sure you extend the correct classes. All of the controllers and models extend the CakeBlogAppController and CakeBlogAppModel. Now if you want to override the views of the cake_blog plugin you can put those in your app/views . The other catch is that while layouts are available in the individual plugins, the css and images must be in the webroot. We recommend building your plugins with var $useDbConfig = ‘pluginname’; in the PluginNameAppModel. Then you would add a var $pluginname; setting to your app/config/database.php. Makes sense, doesn’t it.

The plugin system in CakePHP can be a powerful tool to extend your applications.

Plugins are mini applications consisting of:

Models

Views

Controllers

app/plugins/blog/blog_app_controller.php

<?php
class BlogAppController extends AppController 
{
}
?>

app/plugins/blog/blog_app_model.php

<?php
class BlogAppModel extends AppModel
{
}
?>

app/plugins/blog/controllers/posts_controller.php

<?php
class PostsController extends BlogAppController 
{
    var $name = 'Posts';
}
 
?>

app/plugins/blog/models/post.php

<?php
class Post extends BlogAppModel
{
    var $name = 'Post';
}
?>
 
docs/plugins.txt · Last modified: 2006/02/05 11:44 by dho