Don't repeat yourself
Pragmatic Programming
In this chapter, we will see how we can leverage the extensibility of the eZ Publish CMS to create an extension that can make our project reusable and easily portable to other installations of eZ Publish.
We will now learn how to create an extension for our project in which we'll put our new features, such as design, operators, translations, custom class definition packages, and everything else that we will build in the next chapters.
In eZ Publish, an extension is like a plugin through which you can add new functionality to the CMS without changing the standard software kernel. The eZ Publish extension system is very powerful, as it allows the CMS to be extended in different ways, such as adding new features, or changing the standard behavior of the system's basic functionality.
With this system, you can keep the CMS constantly upgraded to the latest version without the fear of losing your code. In fact, in most cases, the extension will continue to run and in the worst case, you should also upgrade the extension to make it compatible with the new version.
It's possible to create different kind of extensions, such as:
The extension folder needs to use a standard structure to be integrated in the CMS.
In the following table, we can see the complete structure that accommodates all types of extensions:
Extension subdirectories |
Description |
---|---|
|
New actions for forms |
|
Definitions of new template operators or template functions |
|
Custom shell scripts |
|
Custom PHP classes for modules, template operators, template functions, and cronjobs |
|
Custom cronjobs scripts |
|
Definitions for new datatypes |
|
Files related to the design |
|
Custom workflow events |
|
One or more modules with views, template, and fetch functions. |
|
Custom class packages |
|
Configuration files |
|
Translation files |
The directory structure shown above is a complete structure, but the structure that we will use will depend on the type of extension that we need, so some directories will not be necessary. For example, a Template Operator extension only requires the directories autoloads/
and settings/
in a module extension. A module extension, instead, only requires the directories modules/
and settings/
, and maybe the design/
directory.
For our project, we'll make an extension for extending the standard design, standard operators, standard translation files, and standard classes.
3.145.87.161