eZ Community » Forums » Developer » DataType with more than 1 field ?...
expandshrink

DataType with more than 1 field ? howto ?

DataType with more than 1 field ? howto ?

Wednesday 30 November 2011 10:02:39 pm - 4 replies

Hi there, I would like to know how to create complex datatype with more than 1 field.

Until now, I used a simple data_text field with a separator (I simply explode the string in templates when I need it).

But now, I have long text to store with more complex formats.

So, I don't think that a single text field is a correct solution.

  • Is there a way to do it directly in eZ ?
  • Have I to create a table in the database to store my informations ?
  • Another solution ?

Thanks,

Damien

Wednesday 30 November 2011 10:29:13 pm

Hello Damien,

 

Consider storing your content within xml as it provides for greater storage opportunities here.

I would stick with xml storage unless you absolutely require something it can not easily provide. The best practice here is to avoid separate db tables as much as humanly possible.

Still ... I believe you can alternatively store at least part of your content related to the datatype within a persistant object (custom table).

See the nxc_string datatype for an implementation reference, http://projects.ez.no/nxc_string

 

I hope this helps ....

 

Cheers,

Heath

Thursday 01 December 2011 3:38:33 am

Hello Damien,

I think you can also make use of the other (unused) related database table fields available for additional storage (mind the max lengths in play for each may be different).

Re: http://doc.ez.no/schemadoc-450/tables/ezcontentobject_attribute.html
From: http://doc.ez.no/eZ-Publish/Technical-manual/4.x/Reference/Database-schema

This is what I would leverage to it's fullest before I gave out and move into a separate persistent object.
Still .. if your just looking like examples of other datatypes there are quite a few available to review, some more complete than others naturally.

 

You can always review the datatypes provided by default.
I think most store without separate tables as this is the best practice,
take a look at some of the more complex datatypes here and see just how far eZ takes this concept*

https://github.com/ezsystems/ezpublish/tree/master/kernel/classes/datatypes
https://github.com/ezsystems/ezpublish/blob/master/kernel/classes/datatypes/ezmultioption2/ezmultioption2.php
* https://github.com/ezsystems/ezpublish/blob/master/kernel/classes/datatypes/ezmatrix/ezmatrixtype.php

 

I saw this one today and though of your forum thread (seems to use xml and not separate tables, at least in part)

http://svn.projects.ez.no/xrowmet...es/xrowmetadata/xrowmetadatatype.php

 

Then there are the datatypes published on projects.ez.no (warning, not all are relevant or use separate tables)

http://projects.ez.no/types/ez_publish/datatype/

 

Random threads found in research mode (it's cool, you don't have to follow them all, it's just for the record)

eZsurvey seems to use separate tables (you can see the reverse aspects the comments above of how in the following, they store in separate tables and have gone to lengths to do so),

https://github.com/ezsystems/ezsurvey/blob/master/modules/survey/classes/ezsurvey.php

 

eZstarrating seems to also use separate tables,

https://github.com/ezsystems/ezstarrating/blob/master/packages/ezstarrating_extension/ezextension/ezstarrating/classes/ezsrratingdataobject.php

 

I really like this article on the subject of persistent object (better than the ezpedia stub),

http://share.ez.no/layout/set/print/learn/ez-publish/a-quick-and-friendly-introduction-to-ezpersistentobject

 

... so damien, what kind of datatype are you thinking about making?

cheers,
//kracker

Drops:
- "This sh** is eZ ..."
- "Hi how are you ..."
- "...zzzzzz..."
- "dead ... ghost buster"
- "that's why you ... that's why you ..."

Theme song: Birdman ft Nicki Minaj & Lil Wayne -- 'Y.U. MAD' ... ???

Mirror: http://www.youtube.com/watch?v=klvkahk22Bo

Modified on Thursday 01 December 2011 3:40:08 am by // kracker

Thursday 01 December 2011 9:13:23 am

... so damien, what kind of datatype are you thinking about making?

I would like to create an SEO datatype.

I have to store a lot of datas for all pages and maybe how to use those datas (with rules to apply on fields).

Thank you guys, I will read all those documentations and I'll give you feedbacks.

Cheers

Saturday 03 December 2011 2:25:47 am

Hello Damien,

 

No worries. Happy to help.

I took a moment this evening to look through all the extensions on GitHub by eZ Systems. These are all extensions that eZ Systems chose to migrate to git and seem to be actively updated as well as well designed (better examples for reference?). I think if you wanted to look for ideas it could be better to get them from some of the very best works from eZ Systems.  

I think this list is of greater interest for review and study than the projects.ez.no datatype hunt that compares. 

I found create table sql files in the following extensions. I think these use persistent objects / separate tables for storage at some level. Though you would still need to review them at some level to really get an idea if you can learn from their example.

https://github.com/ezsystems/eztags/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezevent/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezsurvey/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezfind/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezscriptmonitor/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezstyleeditor/blob/master/sql/mysql/mysql.sql

https://github.com/ezsystems/ezxmlexport/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezsi/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezmbpaex/blob/master/sql/mysql/mbpaex.sql

https://github.com/ezsystems/ezcomments/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezstarrating/blob/master/packages/ezstarrating_extension/ezextension/ezstarrating/sql/mysql/mysql.sql

https://github.com/ezsystems/ezgmaplocation/blob/master/packages/ezgmaplocation_extension/ezextension/ezgmaplocation/sql/mysql/mysql.sql

https://github.com/ezsystems/ezlightbox/blob/master/sql/mysql/schema.sql

https://github.com/ezsystems/ezflow/blob/master/packages/ezflow_extension/ezextension/ezflow/sql/mysql/mysql.sql

 

Wow, I didn't think there would be so many (extensions with po use) when I started looking happy.gif Emoticon

I looked through almost all repositories of ezsystems on github to make this list so it should be fairly complete. Though it still is only a very ruff starting point from which to use to choose which extensions you review (perhaps for similar usage or use cases which apply to your requirements, needs and desires).

 

I look forward to hearing more about your advances towards increased storage potential actualized/realized for your SEO extension (it sounds cooler then the work I've been doing lately at least, XD have a great weekend!)

 

I hope this helps ... if not you today, then others in the distant future.

 

Cheers,

Heath

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from