Skip to the content
Documentation
Help Start
Reading in:
  • German: 9,059 of 9,059 pages
About the help in other languages
All help pages

Cookbook

Worked examples for the common tasks of building on Exponential, from an extension skeleton to a custom datatype, a cronjob and a Velocity deploy, each checked against the code of this release.

Download as PDF

Address: https://doc.exponential.earth/exphelp/viewer/examples/cookbook/README.md

On this page

Cookbook

Each page of the cookbook builds one thing from start to finish: the files you write, the settings that switch them on, the command that checks them and what goes wrong most often. The pages build on each other through one example extension, expexample, so the code of one page is reused by the next. Read An extension skeleton first if you have never made an extension.

Every example was written from the code of this release and checked where that is cheap: PHP files with php -l, templates with bin/php/eztemplatecheck.php, XML files with xmllint. Each page says what was checked and lists the source files it was derived from. Nothing here was run against a production database; try every example on a copy of your site first.

The recipes

TaskPageWhat it touches
Start an extension of your ownAn extension skeletonextension/<name>/, ezinfo.php, extension.xml, composer.json, ActiveExtensions[], the autoload array
Create a content classCreate a content classSetup > Classes, or eZContentClass and eZContentClassAttribute in a script
Change how one page or class looksA template overrideoverride.ini.append.php, design/<design>/override/templates/, the override cache
Add a template operatorA custom template operatorautoloads/eztemplateautoload.php, [TemplateSettings] ExtensionAutoloadPath[]
Add a page with its own address and policyA custom module and viewmodules/<module>/module.php, module.ini [ModuleSettings], $FunctionList, Roles and policies
Store a new kind of fieldA custom datatypedatatypes/<type>/<type>type.php, content.ini [DataTypeSettings], the datatype templates
Run code when content is publishedA workflow eventeventtypes/event/<type>/, workflow.ini [EventSettings], Setup > Workflows and Triggers
Run code on a scheduleA cronjobcronjobs/, cronjob.ini [CronjobSettings] and [CronjobPart-<part>], the crontab
Read content as JSON from a script or the browserREST and JSON callsezjscore server functions, ezjscore.ini [ezjscServer_<name>], the REST API below /api/
Serve several sites from one installationSeveral sites: siteaccessessite.ini [SiteAccessSettings], settings/siteaccess/<name>/, VarDir, CacheVarDir
Translate the texts of an extensionTranslationstranslations/<locale>/translation.ts, ezpI18n::tr(), |i18n, TranslationExtensions[]
Make pages fast and keep them currentCachingthe view cache, cache-block, ezcache.php, Velocity's response cache
Put a PHP change liveDeploying with Velocityexp:velocity deploy and its steps
Turn what you configure into a migrationRecord an administrator sessionexp:migration:record:*, Setup > Migrations > Recording, exp:migration:generate --from-recording

The example extension at a glance

extension/expexample/
├── ezinfo.php                         what the extension is (Setup > About, Setup > Extensions)
├── extension.xml                      the same, read first; the same version number
├── composer.json                      when it is installed with Composer
├── autoloads/                         template operators (custom-template-operator.md)
├── classes/                           classes found through the autoload array (rest-json-fetch.md)
├── cronjobs/                          cronjob scripts (cronjob.md)
├── datatypes/expcolor/                a datatype (custom-datatype.md)
├── eventtypes/event/explogpublish/    a workflow event (workflow-event.md)
├── modules/expexample/                a module with two views (custom-module-view.md)
├── design/standard/templates/         its templates; design/standard/javascript/ its scripts
├── translations/ger-DE/               its German texts (translations.md)
└── settings/                          *.ini.append.php: what switches each part on

The names follow the project's convention for new code: the extension, its module and its classes start with exp (expexample, expExample...), never with ez.

Reference material

The cookbook shows how; the reference areas list what exists, generated from the code:

The coding rules and the pattern catalogue (how code, templates and documentation are written in this project) are in the standards; the cookbook follows them and does not repeat them.

Something wrong on this page? Report an error

Documentation license

This documentation is free documentation, licensed under the GNU Free Documentation License 1.3 or later.

Exponential Copyright © 1998-2026 Exponential Foundation and 7x