eZ Community » Forums » Developer » create an new datatype with two fields
expandshrink

create an new datatype with two fields

create an new datatype with two fields

Thursday 19 July 2012 11:23:40 am - 3 replies

Hi,

I would like create a new datatype with two fields. The first field will be a simple lineText and second field will be a textxml with tinymce.

I think to use an single file : "myDataTypetype.php". In this file, I will declare two fields.

What is the best practice to develop this new datatype ?

 

Thursday 19 July 2012 11:59:28 am

HI Saito and welcome.

How experienced are you with ezpublish/php?

This will be a difficult thing to do because of the xmltext attribute of the attribute - and why it hasn't been done before in projects (I don't think?)

The problem is that any interaction with existing xmltext/ezoe functions will be looking for the xmltext to be in contentobject_attribute.data_text in the database - yet that's exactly where the xml for your attribute is going to have to be.

I recently got around this by storing the xmltext in a custom table... but, like I said: difficult.

Depending on your needs, you would probably be better off just using two attributes in the class and modifying your templates to do whatever it is that you're trying to with both of these fields in on attribute.

Or, you may be able to get around this by creating a class with a string and a xmltext attribute and use that as your content depending on whether or not it's a child of whatever object you need it for. 

This is what has been done in other custom datatypes (ezsurvey and cjw_newsletter come to mind).

Thursday 19 July 2012 12:48:40 pm

Hi Steven,

I develop for three months with ezPublish. I am an beginner.

Aim of my datatype is to associate at any type of class in ezPublish. For my datatype, I do intend to work with a specific table with eZPersistentObject.

My problem is I do not see how to use foobar tinymce with an xmltext field.

 

Thanks for your advices. I will develop my custom datatype with the ezsurvey example.

Modified on Thursday 19 July 2012 2:23:38 pm by Gérald Rose-Adélaïde

Thursday 19 July 2012 1:47:56 pm

You might want to also take a look at the option datatype.  If you don't care about what ezoe is doing and/or aren't looking to use functions from the xmltext datatype then you can probably reuse the "columns" block for some arbitrary xml.  I recently did that to combine the option and matrix datatypes into one - I just haven't had the time to clean that up and put it on projects yet.

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from