Forums / Developer / Using kernel classes in custom extension/datatype

Using kernel classes in custom extension/datatype

Author Message

Emil Lazaro

Thursday 18 October 2007 10:16:09 am

I am trying to create a new datatype, where I would need some simple price validation. I am new to eZPublish, so I am not sure whether I am allowed to use another datatype in my datatype, or even call some of the basic classes. I noticed while looking at the existing datatypes that ezprice for example is using the eZSimplePrice class, just not sure if this is a good practice, or even if it's possible. The alternative is to write my own function in the new class, but then this will leave it out of synch with the rest of the site.
Any advice or input would be would be useful - thanks

Damien Pobel

Thursday 18 October 2007 10:51:55 am

Hi Emil,

You can use classes, functions from eZ Publish kernel in extensions and for most types of extension you have to do that. For example, for a custom datatype, you have to define a class which should look like :

<?php
include_once( "kernel/classes/ezdatatype.php" );

class yourDatatype extends eZDatatype
{

}
?>

Remember to always include files from the root of your eZ Publish installation.

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

Emil Lazaro

Thursday 18 October 2007 12:02:38 pm

Thanks,

does that apply to the classes of the core extensions and datatypes, i.e. instead of using \kernel\shop\classes/ezsimpleprice.php, can I use the class in /kernel/classes/datatypes/ezprice/ezpricetype.php ?