Short description
-----------------
1. Can I put my plugin outside of plugins/personal directory?
I will like to have application specific plugins.
2. The class name of plugin must start with "Dwoo_"?
I want to use a name like AppName_
Maybe you can implement something like Zend Framework
Zend_Controller_Action_HelperBroker::addPath(APPLICATION_ROOT_PATH . '/library/AppName/Controller/Action/Helper', 'AppName_Controller_Action_Helper');
3. I want to write a plugin that is extending foreach plugin... but to have different paramteres... I run PHP in strict mode and I getting an warning that I should have the same parameters. Can you tell me what is the best way to extend a plugin:
public function init($from, $id, $parent=0, $offset=-1, $count=0, $item=null, $name='default', $implode=null) {
parent::init($from, null, $item, $name, $implode);
}
Jordi Boggiano at Wednesday 24 March 2010 12:18:50 UTC
Yes, you can use $dwoo->getLoader()->addPluginDirectory() to add other directories to the autoloaded plugin paths. It will scan all files though so those directories should only contain dwoo plugins, and files must be called funcName.php
No, but it's easier if it does since Dwoo will autoload those from the plugin directories.
For function-plugins, they can be called just function foo() and you can call them from the templates, for block plugins and plugins written as classes, it's more tricky.
Check out http://wiki.dwoo.org/index.php/WritingPlugins for default naming docs, if you want to name them differently, you need to either implement your own Dwoo_Loader that will load them automatically, or you need to add them all by hand to the Dwoo instance with $dwoo->addPlugin, see http://dwoo.org/_phpdoc/Dwoo/Dwoo.html#addPlugin
Extending foreach is really difficult if you don't have a good understanding of what's happening at compile time. Maybe you can write a plugin that will manipulate an array so you call use it together with foreach like: {foreach transform($array) foo}{$foo.bar}{/foreach} ? Extending plugins is a bit tricky because of the function signature since php in strict mode complains about that, you can however copy it in your own plugin directory and even call it foreach and it will override the default dwoo one.
I hope this helps.
Jordi Boggiano at Wednesday 24 March 2010 12:20:34 UTC
Trying to fix the markup of the original post
emanuel at Friday 26 March 2010 06:19:46 UTC
Thank you Jordi... this was very helpful. For extension of foreach: I had copy & paste from foreach plugin and modified a lot... (I needed 2 nested foreach so in the final extending was not an option).
emanuel at Friday 26 March 2010 08:57:16 UTC
One note... $dwoo->getLoader()->addPluginDirectory() should be $dwoo->getLoader()->addDirectory()
Also if anybody is using Dwoo_Adapters_ZendFramework_View you can get the loader by doing $viewAdapter->getEngine()->getLoader()