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

eZ debug

Timing: Jan 18 2025 05:06:33
Script start
Timing: Jan 18 2025 05:06:33
Module start 'content'
Timing: Jan 18 2025 05:06:34
Module end 'content'
Timing: Jan 18 2025 05:06:34
Script end

Main resources:

Total runtime1.0169 sec
Peak memory usage4,096.0000 KB
Database Queries191

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0056 588.9609180.8125
Module start 'content' 0.00560.8953 769.7734486.6875
Module end 'content' 0.90100.1159 1,256.4609334.0938
Script end 1.0168  1,590.5547 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00410.4076210.0002
Check MTime0.00160.1544210.0001
Mysql Total
Database connection0.00070.067110.0007
Mysqli_queries0.942392.66571910.0049
Looping result0.00160.15681890.0000
Template Total0.989797.320.4949
Template load0.00190.190320.0010
Template processing0.987897.137620.4939
Template load and register function0.00010.012410.0001
states
state_id_array0.00110.111410.0011
state_identifier_array0.00090.086420.0004
Override
Cache load0.00170.1713850.0000
Sytem overhead
Fetch class attribute can translate value0.00100.093730.0003
Fetch class attribute name0.00140.141920.0007
XML
Image XML parsing0.00050.049030.0002
class_abstraction
Instantiating content class attribute0.00000.000420.0000
General
dbfile0.00490.4817210.0002
String conversion0.00000.000530.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
2content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
14content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
15content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 33
 Number of unique templates used: 5

Time used to render debug report: 0.0002 secs