eZ Community » Learn » eZ Publish » An Introduction to Developing eZ...

An Introduction to Developing eZ Publish Extensions

Friday 10 December 2010 10:24:31 am

  • Currently 5 out of 5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

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:

  • Access to the database (eZ Framework – class eZPersistentObject)
  • Access to .ini configuration files (eZ Framework – class eZINI)
  • Access to GET and POST session variables (eZ Framework – class eZHTTPTool)
  • Creation of custom debug messages / log files (eZ Framework – class eZDebug)
  • Use of the privilege system for new views of a module
  • Extending the template system for your own template fetch functions or operators

Requirements

To work through the tutorial, eZ Publish first 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, on the system command line we navigate to the directory extension/ beneath the main eZ Publish directory and create a new directory called jacextension/ with the following subdirectories 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: In INI entries be careful not to leave blank spaces at the end of lines, 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

36 542 Users on board!

Tutorial menu

Printable

Printer Friendly version of the full article on one page with plain styles

Author(s)

Proudly Developed with from