Creating a new extension

Now we will study the example “jacextension” to learn the basics of extension development in eZ Publish. We will walk through the steps of creating an extension and will look at the basic PHP classes in the eZ Publish Framework.

The tutorial will cover the following concepts:

Requirements

To work through the tutorial, eZ Publish must be properly installed (download the latest version here). To do this, create a default site using the eZ Publish Setup Wizard, specifying “URL” in the siteaccess configuration and a MySQL database called “ezp_plain” (character set utf-8).

This creates two siteaccesses: plain_site and plain_site_admin, accessed through the following URLs:
http://localhost/ez/index.php/plain_site (User view)
http://localhost/ez/index.php/plain_site_admin (Administrator view)
(localhost/ez/ is the root path of the eZ Publish directory.)

Setting up the extension

Now we will create and activate a new extension called “jacextension”. It will contain one module called “modul1”, with a view list that runs the PHP script "list.php". To do this we navigate to the directory extension/ beneath the main eZ Publish directory on the system command line and create a new directory called jacextension/ with the following sub-directories and PHP files:

ez/
|-- extension/
|   |-- jacextension/
|   |   |-- modules/
|   |   |   |-- modul1/
|   |   |   |   |-- list.php
|   |   |   |   |-- module.php
|   |   |-- settings/
|   |   |   |-- module.ini.append.php

In the configuration file module.ini.append.php we tell eZ Publish to search for modules in "jacextension". This will make eZ Publish try to load all modules (such as modul1), which are in the directory extension/jacextension/modules/ .

Hint: Be careful not to leave any blank spaces at the end of lines in INI entries, as the variables might not be parsed correctly.

<?php/* #?ini charset="utf-8"?
# tell ez publish to search after modules in the extension jacextension
[ModuleSettings]
ExtensionRepositories[]=jacextension
# For eZ Publish 4.1 and up you'll need to specify your module name as well
ModuleList[]=modul1
*/
?>

Listing 1. Module configuration file: extension/jacextension/settings/module.ini.append.php

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2013 eZ Systems AS (except where otherwise noted). All rights reserved.