Forums / Discussions / An Introduction to Developing eZ Publish Extensions

Wednesday 29 July 2009 2:33:09 am - 11 replies

» Read full tutorial

Introduction

Most Content Management System requirements can be fulfilled by eZ Publish without any custom PHP coding. But sooner or later experienced eZ Publish implementers get to the point where a project needs some special functionality and it becomes necessary to develop extensions.

(This tutorial was initially published on 21/01/2008, and refreshed to match the 4.x series on 10/12/2010)

Author Message

Dan Parchman

Thursday 31 December 2009 12:11:29 pm

The code on page 8 which reads:
-----------------------------------------------

class JACExtensionData extends eZPersistentObject
{
/*!
Konstruktor
*/
function JACExtensionData( $row )
{
$this->eZPersistentObject( $row );
}

/*!
Definition of the data object structure /of the structure of the database table
*/
function definition()
---------------------------------------------

In eZ Publish 4.x should be:
-------------------------------------------

class JACExtensionData extends eZPersistentObject
{
/*!
Konstruktor
*/
function JACExtensionData( $row )
{
$this->eZPersistentObject( $row );
}

/*!
Definition of the data object structure /of the structure of the database table
*/
static function definition()
------------------------------------------------

Then it works!

Dan Parchman

Thursday 31 December 2009 1:41:35 pm

After adding the new function_definition.php file (page 9 - Template Fetch Functions) update the extension auto-load array by clicking the "Regenerate autoload arrays for extensions" button in the Admin panel Settings -> Extensions.

Sendo Lat

Thursday 25 February 2010 11:42:16 pm

Thanks for this information.

BTW, if you have interest in these topics,
loan problems, how to lose weight fast?
which is the best travel agency? and baby care problems?

Welcome to my blog.

Ivan Švogor

Wednesday 29 September 2010 9:45:14 am

After clearing all the cache I still get the message:

No template could be loaded for "modul1/list.tpl" using resource "design"

please help :)

Gaetano Giunta

Friday 22 October 2010 4:15:37 am

For an extension that adds one or more tables to the db, it is important to create a share/db_schema.dba file where these new tables are described.

This way when the admin goes to the "Setup/Upgrade Check/Check db consistency" page

- he will note get a suggestion to drop the table

- he will get a suggestion with the sql command to create the table if the table does not exist

This is true since eZP 4.3

The format for db_schema.dba is propietary to eZ. You can find examples in ezfind, ezflow and other extensions from eZ Systems

To generate that file you can use the ezsqldumpschema.php script. Take care: right now it will create a file with the definition of the whole db, so you should either use it in a db where you only have your new table(s) or clean up by hand the generated .dba file

Principal Consultant International Business
Member of the Community Project Board

Leo Mik

Tuesday 26 October 2010 4:16:27 am

Hey Gaetano, thanks for help!

André R.

Wednesday 15 December 2010 12:26:48 pm

To really be a mirror for best practice, then code examples should add phpdoc and use php5 features like __construct and so on, eg:

/**
 * JACExtensionData does....
 */
class JACExtensionData extends eZPersistentObject
{
   /**
    * Constructor
    *
    * @param array $row Hash of attributes for new <span class="Apple-style-span" style="font-size: 13px; " mce_fixed="1">JACExtensionData</span> <span class="Apple-style-span" style="font-size: 13px; " mce_fixed="1"><span>object</span></span>
    */ 
    function __construct( $row )
    {
        parent::__construct( $row );
    }

   /**
    * Definition of the data object structure /of the structure of the database table
    *
    * @return array Hashed array with table definition of this p<span class="Apple-style-span" style="font-size: 13px; " mce_fixed="1">ersistent object</span>
    */ 
    static function definition()

Additionally, member variables should probably be protected/private to make sure attribute() function is used outside the class.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Jérôme Vieilledent

Wednesday 22 December 2010 10:14:40 pm

Thanks André. I just fixed this.

Mauricio Sánchez

Friday 11 February 2011 12:29:32 pm

Hi Guys!

Is there a way to create a custom locale file ([email protected]) inside an extension?

Any help will be appreciated!

Eirik Alfstad Johansen

Friday 01 July 2011 1:38:57 am

I thought best practice was to put operators in a separate /operators folder. Is that not the case anymore? Or am I simply mistaken?

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Nicolas Pastorino

Friday 01 July 2011 8:41:36 am

"

I thought best practice was to put operators in a separate /operators folder. Is that not the case anymore? Or am I simply mistaken?

"

Template operators ? Placing them in the 'autoloads' directory, at the root of the given extension directory, is the usual practice.

Cheers,

--
Nicolas Pastorino
Director Community - eZ
Member of the Community Project Board

eZ Publish Community on twitter: http://twitter.com/ezcommunity

t : http://twitter.com/jeanvoye
G+ : http://plus.tl/jeanvoye

You must be logged in to post messages in this topic!

eZ debug

Timing: Jan 18 2025 02:35:55
Script start
Timing: Jan 18 2025 02:35:55
Module start 'content'
Timing: Jan 18 2025 02:35:55
Module end 'content'
Timing: Jan 18 2025 02:35:55
Script end

Main resources:

Total runtime0.1480 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0083 588.6797180.8047
Module start 'content' 0.00830.0063 769.4844114.7891
Module end 'content' 0.01460.1332 884.2734531.7500
Script end 0.1478  1,416.0234 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00382.5815200.0002
Check MTime0.00161.0501200.0001
Mysql Total
Database connection0.00130.887510.0013
Mysqli_queries0.101068.24411410.0007
Looping result0.00130.85611390.0000
Template Total0.132889.710.1328
Template load0.00110.719810.0011
Template processing0.131789.000810.1317
Override
Cache load0.00070.460210.0007
Sytem overhead
Fetch class attribute can translate value0.00060.389310.0006
XML
Image XML parsing0.00030.233210.0003
General
dbfile0.00302.0544200.0002
String conversion0.00000.005630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs