Forums / Developer / It's possible to Extend provided datatypes?

It's possible to Extend provided datatypes?

Author Message

Carlos Revillo

Wednesday 24 February 2010 11:45:46 am

Hi There.

We need a specific issue for our project. Functionality is almost entirely provided by ezflow with ezpagetype, but we need some specific things to be added.

So, we thought to build our customezpage datatype. But instead of copying ezpagetype and modifying the necessary we thought about extending eZPageType class.

So, we have now something like

class customEZPageType extends eZPageType
{
    const DATA_TYPE_STRING = 'customezpage';

    /**
     * Constructor
     *
     */
    function __construct()
    {
        parent::__construct( self::DATA_TYPE_STRING, "Custom Layout" );
    }
    
}

eZDataType::register( customEZPageType::DATA_TYPE_STRING, "customezpagetype" );

Seems to work, but there's a annoying thing that can be confusing to users. At datatypes combo while editing class, i have two 'Layout' entries (Layout is the common name given to this datatype, as Block XML or Boolean).

I though the reason is the way ezpagetype::__construct works. There you have

function __construct()
 {
    parent::__construct( self::DATA_TYPE_STRING, "Layout" );
 }

So, no matter what you do from extended ones, because this construct always sends to datatype 'ezpage' as data_type_string and "layout" as 'common name".

Do you think is not good option to extends a provided datatype? I think this could help us doing specificic things wihout having to copy lot of code.

Thank you!.

Carlos Revillo

Thursday 25 February 2010 2:06:36 am

With the help from Bratt at IRC channel, i think i've got a solution. instead of calling parent::__construct, i could just call eZDataType::__construct

So i have now

class customEZPageType extends eZPageType
{
    const DATA_TYPE_STRING = 'customezpage';

    /**
     * Constructor
     *
     */
    function __construct()
    {
        eZDataType::__construct( self::DATA_TYPE_STRING, "Custom Layout" );
    }
    
}

eZDataType::register( customEZPageType::DATA_TYPE_STRING, "customezpagetype" );

Best!

Nicolas Pastorino

Thursday 25 February 2010 2:34:35 am

Looks all good Carlos !

Stupid question : how did you make sure the customEZPageType isused instead of the default class ? It usually is not very easy to override a kernel's datatype.

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

eZ debug

Timing: Jan 17 2025 23:55:49
Script start
Timing: Jan 17 2025 23:55:49
Module start 'content'
Timing: Jan 17 2025 23:55:50
Module end 'content'
Timing: Jan 17 2025 23:55:50
Script end

Main resources:

Total runtime1.3147 sec
Peak memory usage4,096.0000 KB
Database Queries194

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 587.8438180.8125
Module start 'content' 0.00691.1595 768.6563544.1953
Module end 'content' 1.16640.1482 1,312.8516332.7422
Script end 1.3147  1,645.5938 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00400.3057210.0002
Check MTime0.00150.1107210.0001
Mysql Total
Database connection0.00070.051210.0007
Mysqli_queries1.241694.43731940.0064
Looping result0.00240.17911920.0000
Template Total1.285997.820.6430
Template load0.00200.153320.0010
Template processing1.283997.656220.6419
Template load and register function0.00020.014410.0002
states
state_id_array0.00070.056410.0007
state_identifier_array0.00120.087720.0006
Override
Cache load0.00170.1275240.0001
Sytem overhead
Fetch class attribute can translate value0.00110.083230.0004
Fetch class attribute name0.00090.067640.0002
XML
Image XML parsing0.00080.057530.0003
class_abstraction
Instantiating content class attribute0.00000.000640.0000
General
dbfile0.00720.5463270.0003
String conversion0.00000.000630.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
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
6content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 15
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs