Need help to complete a custom datatype

Author Message

Sébastien Antoniotti

Saturday 24 May 2008 10:11:18 am

Hi,

I'm using a custom datatype who stores a birthday date as a data_text (1925-12-20 by ex.).

I'm not the author of this datatype, and I encouter a problem when I try to create instances of the class who uses this datatype from PHP.

The problem is simply that the datatype is empty although the object is correctly created.

To create the object from PHP, I use the eZContentFunctions::createAndPublishObject method, and I set my attribute content like this :

$attributes_content = array(
...
'birthday' 	=> "1925-12-20",
...
);

I have searched into the forum, and I seen that the datatype must implement the storeObjectAttribute method, and my datatype doesn't.

The problem is that into the storeObjectAttribute method, I don't know how to retrieve the value passed to eZContentFunctions::createAndPublishObject...

I'm very lost because this is the first time I work with custom datatypes !

Thanks in advance !

eZ Publish Freelance
web : http://www.webaxis.fr

Kristof Coomans

Saturday 24 May 2008 10:30:21 am

Hi Sébastien

eZContentFunctions::createAndPublishObject() makes use of the fromString() method of the datatype. For a very simple example, see function fromString in kernel/classes/datatypes/ezstring/ezstringtype.php. Good luck! And don't forget to share your enhancement to this datatype ;)

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

Sébastien Antoniotti

Saturday 24 May 2008 11:36:33 am

Hi Kristof,

You put me on the right way !

So here are the two methods I added to this datatype to make it compatible with eZContentFunctions::createAndPublishObject :

function storeObjectAttribute( $contentObjectAttribute )
{
	$data = $contentObjectAttribute->content();
	$data = sprintf('%04d-%02d-%02d', $data['year'], $data['month'], $data['day']) ;
	$contentObjectAttribute->setAttribute( "data_text", $data );
	return false;
}

function fromString( $contentObjectAttribute, $string )
{
	return $contentObjectAttribute->setAttribute( 'data_text', $string );
}

Many thanks !

eZ Publish Freelance
web : http://www.webaxis.fr

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 19 2025 00:28:22
Script start
Timing: Jan 19 2025 00:28:22
Module start 'layout'
Timing: Jan 19 2025 00:28:22
Module start 'content'
Timing: Jan 19 2025 00:28:23
Module end 'content'
Timing: Jan 19 2025 00:28:23
Script end

Main resources:

Total runtime1.0021 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.1484152.6406
Module start 'layout' 0.00800.0036 741.789139.4766
Module start 'content' 0.01150.9891 781.2656548.5859
Module end 'content' 1.00060.0015 1,329.851612.1406
Script end 1.0021  1,341.9922 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.3219160.0002
Check MTime0.00130.1272160.0001
Mysql Total
Database connection0.00120.115210.0012
Mysqli_queries0.941693.9576570.0165
Looping result0.00060.0599550.0000
Template Total0.959395.720.4796
Template load0.00180.181920.0009
Template processing0.957595.542920.4787
Template load and register function0.00010.010210.0001
states
state_id_array0.00190.184710.0019
state_identifier_array0.00090.089120.0004
Override
Cache load0.00140.1426250.0001
Sytem overhead
Fetch class attribute can translate value0.00060.056120.0003
Fetch class attribute name0.00130.134750.0003
XML
Image XML parsing0.00110.109120.0005
class_abstraction
Instantiating content class attribute0.00000.001060.0000
General
dbfile0.00430.4301220.0002
String conversion0.00000.001240.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/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_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