This site has been archived. To learn more about our current products Ibexa Content, Ibexa Experience, Ibexa Commerce head over to the Ibexa Developer Portal

eZ Community » Forums » Developer » how to instanciat a eZDataType classe ?

how to instanciat a eZDataType classe ?

how to instanciat a eZDataType classe ?

Tuesday 24 June 2008 4:56:57 pm - 5 replies


I d'ont understand how to use the eZDataType classe.
In the documentation, I've found :

eZDataType::eZDataType(  	$dataTypeString,
		$properties = array()	 
Initializes the datatype with the string id $dataTypeString and the name $name.

So I've write :

$l_OBJ_File =& eZDataType::eZDataType("dataType", "name");

and I got the message :
Fatal error: Call to undefined method: stdClass->isindexable() in C:\eZpublish\ezpublish\kernel\classes\ezdatatype.php on line 88

I use an ezpublish 3.10. Is it a bugging version for this classe ? What's wrong in my code ?

Thanks for your help.

Thursday 03 July 2008 11:33:10 am

eZDataType is meant as base class for other datatypes.

I am not sure what you want to do, but trying to instantiate a datatype doesn't make much sense. The content needs to be stored in a attribute in a contentobject. Once you have the content object, the different datatypes will be instantiated for you

Best regards,

Thursday 03 July 2008 11:55:16 am

Thanks for your answer.

Well.... My first problem was to read a file content from an uploaded file and during all my investigations, I've found the classe eZDataType which seems to be ok to do the job for me.

But reading your answer I should be on a wrong way.

Thursday 03 July 2008 11:29:36 pm

It depends on where you're handling uploaded files, but if you're in your own module I suggest you take a look at the eZHTTPFile class. You can find it in the lib/ezutils/classes dir.

If that's not what you're trying to do, please explain your problem in greater detail happy.gif Emoticon

Friday 04 July 2008 10:18:22 am

Thanks Hans Melis,

Your right, my problem is not well explain.
- The user, upload a file in the Back Office in a file object. For that, I've create a file object in the BO, in a specific folder. The user will use always the same object, so I'll have different version. This is a text file.
- With a cron job I have to import in a specific database datas stored in the file. For that, I have to read my file content with a php script, and my trouble is to point that file.

But I don't know how to read my text file content. So I search in eZDataType classe without success. And I'm not sure that the eZHTTPFile class is the good one.

Friday 04 July 2008 1:17:20 pm

eZHTTPFile is indeed not what you need in your case. You are actually trying to access a file that is a part of a content object.

So first of all, you need to fetch the object in some way. Once you have it, you'll have an instance of the eZContentObject class. Objects of that class have a method called <i>dataMap</i>. That method returns an array with the following structure:
- key: identifier of the attribute as specified in the content class
- value: instance of eZContentObjectAttribute

The class eZContentObjectAttribute actually (for the real data at least) wraps around the datatype. If you query the eZContentObjectAttribute instance for content(), you will get the content that has been stored by the corresponding datatype. That content can be a scalar value, an array or even an object of class. The latter is the case for attributes of the type file.

The datatype for files is called ezbinaryfile (kernel/classes/datatypes) and the content of that datatype returns an instance of the class eZBinaryFile.

That should get you on the road. I obviously left some things out, but the goal is that you actually learn something. So it's your task to connect the dots blunk.gif Emoticon


Modified on Friday 04 July 2008 1:18:43 pm by Hans Melis


You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu

Proudly Developed with from