How to create a new data type whit 4 attribute

Author Message

Rhino Vincent

Tuesday 04 September 2007 4:24:33 am

I woold like to create a new datatype whit 4 attribute
.text_field
.text_block
.image
.checkbox

I all ready read this tutoriel http://ez.no/ezpublish/documentation/development/extensions/datatypes/new_datatype

and this what i did :

<?php

// Include the super class file
include_once( "kernel/classes/ezdatatype.php" );
// Include the file which will be used to validate email
/*include_once( "lib/ezutils/classes/ezmail.php" );*/
/* text */
define( "EZ_DATATYPESTRING_TEXT", "ezad_text" );

 

class eZAdType extends eZDataType
{

/*!
Construction of the class, note that the second parameter in eZDataType
is the actual name showed in the datatype dropdown list.

*/
function eZAdType()

{
$this->eZDataType( EZ_DATATYPESTRING_EZAD, "ezad" );
}

function validateObjectAttributeHTTPInput( &$http, $base,
&$contentObjectAttribute )
{

}
function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute )
{
if ( $http->hasPostVariable( $base . "_data_text_" .
$contentObjectAttribute->attribute( "id" ) ) )
{
$data =& $http->postVariable( $base . "_data_text_" .
$contentObjectAttribute->attribute( "id" )
);
$contentObjectAttribute->setAttribute( "data_text", $data );
}
return false;
}

/*!

Store the content. Since the content has been stored in function
fetchObjectAttributeHTTPInput(), this function is with empty code.
*/

function storeObjectAttribute( &$contentObjectattribute )
{
}
/*!
Returns the content.
*/
function &objectAttributeContent( &$contentObjectAttribute )
{
return $contentObjectAttribute->attribute( "data_text" );
}

/*!
Returns the meta data used for storing search indices.
*/

function metaData( $contentObjectAttribute )
{
return $contentObjectAttribute->attribute( "data_text" );
}

/*!
Returns the text.

*/
function title( &$contentObjectAttribute )

{
return $contentObjectAttribute->attribute( "data_text" );
}

}
eZDataType::register( EZ_DATATYPESTRING_AD, "ezadtype" );
?>

can u tell me what i have to do next ?

Olivier Ouin

Tuesday 04 September 2007 11:32:04 am

What your are trying to do sounds a bit strange to me ...

You have "began" to write a datatype, but your needs description sounds like you should simply create a custom class with the given datatypes.

Are you sure that creating a new datatype is really what you need ?

If it's the case, you have know that the RAD that provided you the php code that you have posted below just have write the minimal structure of your new datatype.
You'll have to implement at least these methods to have it begin to work, but there is (a lot) more to overload from the eZDataType class (see /kernel/classes/ezdatatype.php and read all comments in it).

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 30 2025 22:27:30
Script start
Timing: Jan 30 2025 22:27:30
Module start 'layout'
Timing: Jan 30 2025 22:27:30
Module start 'content'
Timing: Jan 30 2025 22:27:30
Module end 'content'
Timing: Jan 30 2025 22:27:30
Script end

Main resources:

Total runtime0.0232 sec
Peak memory usage6,144.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0048 588.2656151.2266
Module start 'layout' 0.00480.0038 739.4922220.7188
Module start 'content' 0.00870.0130 960.2109997.7266
Module end 'content' 0.02170.0015 1,957.937533.9922
Script end 0.0232  1,991.9297 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002811.9917140.0002
Check MTime0.00114.7663140.0001
Mysql Total
Database connection0.00052.119310.0005
Mysqli_queries0.00229.397130.0007
Looping result0.00000.060610.0000
Template Total0.00114.610.0011
Template load0.00083.566010.0008
Template processing0.00020.999110.0002
Override
Cache load0.00062.523810.0006
General
dbfile0.00031.229180.0000
String conversion0.00000.029840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs