Forums / Developer / How to create a new data type whit 4 attribute

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).