Plugins are situated within the plugins folder in the pimcore root directory. For each plugin a separate folder must be created.
The folder structure of a plugin should look as follows:
/plugins
/PLUGIN_NAME
/controllers
/lib
/PLUGIN_LIB
/modules
/PLUGIN_NAMESPACE
/static
/css
/js
/img
/views
plugin.xml
The lib folder should contain all PHP libraries and plugin specific libraries, as well as any other php code required by the plugin. Before including external libs, it should be checked if they are not already included by pimcore itself. The lib folder is also the place for the plugin class, which needs to extend the abstract plugin class and implement the plugin interface provided by pimcore. More information on plugin development in the backend is provided in backend development.
All user interface components should be situated in the static folder. Javascript/CSS files are included when the pimcore user interface starts up, provided that they are properly specified in the plugin config. Further information on user interface plugin development is is given in Ext JS frontend development.
Plugins need to be configured in the plugin.xml. The following parameters need to be configured in plugin.xml:
- plugin name (unique identifier = plugin folder) (must not contain spaces)
- plugin nice name (name to be displayed in pimcore)
- plugin icon (icon to be displayed in pimcore)
- plugin description
- plugin server (repository where plugin can be downloaded and updated)
- plugin version and revision (these tags must be available, values are filled at repository checkin)
- source to display in an iframe in the pimcore admin when opening the plugin optins (can be used for your own config form)
- PHP class name of the plugin
- PHP include paths
- PHP namespaces
- Javascript paths
- CSS file paths
- Javascript paths for scripts which should be included in document editmode (new since pimcore build 704)
- CSS paths for stylesheets which should be included in document editmode (new since pimcore build 704)
An example plugin.xml looks like this:
<?xml version="1.0"?> <zend-config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/"> <plugin> <!-- unique identifier = folder name --> <pluginName>Test</pluginName> <pluginNiceName>My Test Plugin</pluginNiceName> <!-- 64 x 64 Pixel Icon --> <pluginIcon>/plugin/Test/static/img/icon.png</pluginIcon> <pluginDescription> Put the description of your Plugin here. It is displayed in Pimcore backend </pluginDescription> <pluginServer>your.pluginrepository.com</pluginServer> <!-- Version, revision and timestamp are updated by createRevision script at check in to plugin server!--> <pluginVersion>1.0.0</pluginVersion> <pluginRevision>1</pluginRevision> <pluginBuildTimestamp>0</pluginBuildTimestamp> <!-- content to include in pimcore admin in a iframe, if pluginIframeSrc is defined, the options button is included and the iframe is shown in an extra tab --> <pluginIframeSrc>/plugin/Test/controller/action</pluginIframeSrc> <!-- className of the plugin which extends Pimcore_API_Plugin_Abstract--> <pluginClassName>Test_Plugin</pluginClassName> <!-- include paths relative to plugin-directory --> <pluginIncludePaths> <path>/Test/path1</path> <path>/Test/path2</path> </pluginIncludePaths> <!-- namespaces to register with autoloader--> <pluginNamespaces> <namespace>Test</namespace> <namespace>Resource</namespace> </pluginNamespaces> <!-- js files needed for pimcore plugin (backend) with path relative to plugin-directory --> <pluginJsPaths> <path>/Test/static/js/test.js</path> </pluginJsPaths> <!-- css files needed for pimcore plugin (backend) with path relative to plugin-directory --> <pluginCssPaths> <path>/Test/static/css/test.css</path> </pluginCssPaths> <!-- js which should be included in document edit mode, path relative to plugin-directory --> <pluginDocumentEditmodeJsPaths> <path>/Test/static/js/editmode.js</path> </pluginDocumentEditmodeJsPaths> <!-- css files which should be included in document edit mode, path relative to plugin-directory --> <pluginDocumentEditmodeCssPaths> <path>/Test/static/css/edimode.css</path> </pluginDocumentEditmodeCssPaths> </plugin> </zend-config>