eZ Community » Forums » Discussions » An Introduction to Developing eZ...
expandshrink

Wednesday 29 July 2009 11:33:09 am - 19 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)

Thursday 31 December 2009 9: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!

Thursday 31 December 2009 10: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.

Friday 26 February 2010 8:42:16 am

The reply has been removed because of violation of forum rules.

Wednesday 29 September 2010 6:45:14 pm

After clearing all the cache I still get the message:

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

please help happy.gif Emoticon

Friday 22 October 2010 1:15:37 pm

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

Modified on Friday 22 October 2010 1:16:35 pm by Gaetano Giunta

Tuesday 26 October 2010 1:16:27 pm

Hey Gaetano, thanks for help!

Wednesday 15 December 2010 9: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.

Modified on Wednesday 15 December 2010 9:30:56 pm by André R

Thursday 23 December 2010 7:14:40 am

Thanks André. I just fixed this.

Modified on Thursday 23 December 2010 7:14:55 am by Jérôme Vieilledent

Friday 11 February 2011 9:29:32 pm

Hi Guys!

Is there a way to create a custom locale file (eng-US@custom.ini) inside an extension?

Any help will be appreciated!

Friday 01 July 2011 10: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?

Friday 01 July 2011 5:41:36 pm

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,

Thursday 02 August 2012 11:37:57 am

I downloaded eZPublis 4.3 and there is a small mistake in example above.

 

When registering template operator in eztemplateautoload.php we need to specify script variable:

$eZTemplateOperatorArray[] = array( 'script' => 'extension/jaxectension/autoloads/jacoperator.php',
                                    'class' => 'JACOperator',
                                    'operator_names' => array( 'jac' ) );

 

This worked for me happy.gif Emoticon

Friday 14 September 2012 11:17:44 am

I have followed your instructions but I get the error:

Undefined module: modul1

What can I have done wrong?

The only difference I see is that I have an installation of eZ 4.7 Demo. So the URL is http://myez.localhost/index.php/ezdemo_site/modul1/list/table/5/%28param4%29/141

Friday 14 September 2012 12:05:20 pm

There is an error in the tutorial! Argh. the module.php should be in modul1 folder

Friday 14 September 2012 12:07:02 pm

Quote from Andreas Wiik :

There is an error in the tutorial! Argh. the module.php should be in modul1 folder

Ops, it is correct here, but wrong here: http://doc.ez.no/Tutorials/Develo...-extensions/Creating-a-new-extension

Friday 14 September 2012 3:32:34 pm

Hi Andreas,

sorry for that. I will inform the ez responsable for that to fix the ez doc.

Cheers Felix

 

=> the doc is fixed now

Modified on Tuesday 18 September 2012 11:59:10 am by Felix Woldt

Monday 17 September 2012 2:53:58 pm

I'm unable to make the fetch functions work. I get an error:

Missing function definition file for module: modul1

But I have created function_defintion.php in modules/modul1

 

The template operators do work though.

Tuesday 18 September 2012 9:41:56 am

That was my mistake sad.gif Emoticon Typo

Tuesday 18 September 2012 1:57:21 pm

Quote from Andreas Wiik :

That was my mistake sad.gif Emoticon Typo

One beer owed to the community blunk.gif Emoticon

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from