Extension development

Author Message

Jérôme m

Monday 04 October 2010 4:18:53 am

I developed a couple of very specific extensions for my own use.

I'm facing a couple of general problems developing extensions and using other people extensions as well witch is the lack of an "official howto".

for example : If I have to handle http inputs, where should I handle that ? In an action ? inside a class ?

That kind of things is handled in very different ways in the various extensions I used witch makes it difficult to understand the code and adapt it.

It also leads to write a lot of code for buiding functions that already exist in the core. For example, I recently used an extension redefining a custom datatype for structuring data that are already handled by ez (dates, booleans, etc.). That leads to write very much code and braking the compatibilité with fetch functions.

I'm also sometimes very surprised to see some general purpose labels like "Remove selected" being translated in the core and in every extension.

I'm often reading advices like "read other people's code", or "study the kernel files" or "use ezdebug" and that's of course very usefull. The only benefit of using a structured expandable system is to be able to use it without having to undertand the whole thing.

Il read a few articles about developing extensions and my question is not "how should I do this or that ?" but is there some sort of "offical" guideline document about that.

Damien Pobel

Monday 04 October 2010 5:32:14 am

Hi Jérôme,

"

for example : If I have to handle http inputs, where should I handle that ? In an action ? inside a class ?

That kind of things is handled in very different ways in the various extensions I used witch makes it difficult to understand the code and adapt it.

"

It depends on your need. If you want to store data in content object you usually need to write a datatype. If you just want to do a specific custom action, you have to do a module/view and if you want to plug your code into an eZ Publish process you'll need to write workflow event type or a custom action or a content edit handler. And there are probably others situations that I do not have in mind currently :-)

"

It also leads to write a lot of code for buiding functions that already exist in the core. For example, I recently used an extension redefining a custom datatype for structuring data that are already handled by ez (dates, booleans, etc.). That leads to write very much code and braking the compatibilité with fetch functions.

"

it's probably needed to fix a limitation of eZ Publish. For instance, the Date datatype is not able to store dates before 1970-01-01 that's why the birthday extension exists.

"

I'm also sometimes very surprised to see some general purpose labels like "Remove selected" being translated in the core and in every extension.

"

In fact, the same sentence in english can be translated in different locale strings depending on the context.

"

Il read a few articles about developing extensions and my question is not "how should I do this or that ?" but is there some sort of "offical" guideline document about that.

"

hum it's difficult to write a doc that covers all the possible cases. So feel free to ask questions in this forum, I think you should always find someone to help you.

Cheers

Damien
Planet eZ Publish.fr : http://www.planet-ezpublish.fr
Certification : http://auth.ez.no/certification/verify/372448
Publications about eZ Publish : http://pwet.fr/tags/keywords/weblog/ez_publish

Jérôme m

Wednesday 06 October 2010 4:59:29 am

Merci Damien,

The fact is : there is an expandable system that needs extensions code to respect certain conventions to function properly. Plus there is a whole system that implements a lot of things allready.

I used an extension that needs to process user posted data. The processing (capture of http vars + various actions) is done inside a class and triggered by a fetch method. The problem is : when the view cache is working the fetch doesn't occur anymore and the processing is not working.

My example is trivial but illustrates the fact that if one doesn't realize one's extension is not fully 'compatible" with the system it's supposed to work with, users are going to spend time solving problems and might even give up and say it's lousy even though it does basically everything they need.

A simple rule could be : handle user posts in that place : ... you can be sure it works 99% of the time.

Rules for making fully compatible extensions => it works immediatly, isn't it what everybody wants ?

I agree that no rule can apply 100%, 99% is far enough.

About asking to people what they would do in this or that situation, I really preffer to know what is made to work that way than relying on what is known to work.

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

eZ debug

Timing: Jan 18 2025 02:55:05
Script start
Timing: Jan 18 2025 02:55:05
Module start 'layout'
Timing: Jan 18 2025 02:55:05
Module start 'content'
Timing: Jan 18 2025 02:55:06
Module end 'content'
Timing: Jan 18 2025 02:55:06
Script end

Main resources:

Total runtime1.1826 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0080 589.0234152.6094
Module start 'layout' 0.00800.0036 741.632839.4219
Module start 'content' 0.01161.1695 781.0547550.5859
Module end 'content' 1.18110.0015 1,331.640616.1875
Script end 1.1826  1,347.8281 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.2827160.0002
Check MTime0.00130.1137160.0001
Mysql Total
Database connection0.00080.070810.0008
Mysqli_queries1.119794.6776570.0196
Looping result0.00060.0547550.0000
Template Total1.145196.820.5725
Template load0.00170.145320.0009
Template processing1.143496.682320.5717
Template load and register function0.00020.013310.0002
states
state_id_array0.00060.048310.0006
state_identifier_array0.00160.139320.0008
Override
Cache load0.00150.1265390.0000
Sytem overhead
Fetch class attribute can translate value0.00070.057620.0003
Fetch class attribute name0.00250.214440.0006
XML
Image XML parsing0.00060.051920.0003
class_abstraction
Instantiating content class attribute0.00000.001140.0000
General
dbfile0.00210.1755160.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
4content/datatype/view/ezxmltags/quote.tpldatatype/ezxmltext/quote.tplextension/ezwebin/design/ezwebin/override/templates/datatype/ezxmltext/quote.tplEdit templateOverride template
1content/datatype/view/ezxmltags/strong.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/strong.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 19
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs