eZ Community » Forums » Developer » Associate fields from 2 classes
expandshrink

Associate fields from 2 classes

Associate fields from 2 classes

Monday 09 January 2012 5:59:52 pm - 11 replies

Hi everybody.

Today I have no idea about this problem!!

I have a class named Person;
I have 2 more classes, called Department and Position.

The problem is that a single person can belong to several Department (ex. Tourism and Culture) and work on a specific Position for each Department(ex. Manager of Tourism and Consultant of Culture ).

I tried to use the Selection field, but I have to insert all values manually and I cannot associate an instance of Department to its set of instances of Position.

Any idea to implement that crazy structure?

 

To be clearer, this is a fake structure of my DB that explain the relation between my classes:

PERSON (id_person, name,....)

TBL_PERS_POS (id_pers, id_pos)  // this one makes the matches between Person and Position

POSITION (id_position, name_position, ...)

DEPARTMENT (id_dept, name_dept,...,fk_id_pos)

 

I'm afraid there's no good solution embedded in Ez Publish... Am I wrong??

 

Really really need your help!

Modified on Tuesday 10 January 2012 12:21:12 pm by Simone Conti

Tuesday 10 January 2012 1:01:04 pm

Hi Simone,

eZ Publish is a CMS with features such as translation features, advanced WYSIWYG editor, etc. That
 a tool to build complex relational databases, if you use CMS features / content classes / object relation attribute, etc. for such a purpose, then you will face performance issues when your database will get bigger and if you have a lot of visitor. As far as I'm concerned I've seen this mistake too many time while auditing critical projects...

Be careful, I'm not saying that you should not use eZ Publish for this kind of content (Person, Department, etc...) but you should consider developing custom content attributes (datatypes) to manage content relations (1-n / n-m / with meta informations such as your TBL_PERS_POS table) etc...

These datatypes will have to be based on what we call an eZPersistentObject (basically, this is a DAO) which will help you abstracting your data from simple MySQL tables (or anything else) and give you the opportunity to use it within your eZ Publish developments (extensions and custom modules/workflow, content classes via a datatype, etc...)

I have to go, try to find some tutorials on eZPersistentObject developments & Datatypes. If you do not find anything, I'll get back to you.

Cheers.

Tuesday 10 January 2012 1:12:20 pm

Hi Arnaud, your answer is exactly what I was afraid of!

I'm not such a good ez-programmer so I'm bit scared of making my own datatypes (although they were the first solution in my mind)!

I'm going to look for some good hint on line, I hope to find my solution.

 

Thank you very much

Tuesday 10 January 2012 3:08:18 pm

Hi Arnaud, your answer is exactly what I was afraid of!

I'm not such a good ez-programmer so I'm bit scared of making my own datatypes (although they were the first solution in my mind)!

I'm going to look for some good hint on line, I hope to find my solution.

 

Thank you very much

Don't be afraid. That is not really a difficult task and I'm pretty sure that you'll get some help from the community. Basically, you will just have to implement some required methods in your PHP classes. I can still remember the day I've discovered Persistent Object in eZ Publish : Waouh !
Believe me it's worth it !

Good start for eZ Persistent Object : http://share.ez.no/learn/ez-publish/a-quick-and-friendly-introduction-to-ezpersistentobject

Good start for Datatypes : http://share.ez.no/learn/ez-publish/creating-datatypes-in-ez-publish-4

You can also read the excellent article from Jérome, written for PHP Solutions Mag. last year : http://www.lolart.net/blog/ez-publish/dossier-ez-publish-dans-le-dernier-php-solutions

Last but not least, if you are willing to use eZ Find for your search feature, developing your own datatype will help you in indexing data the way you want... blunk.gif Emoticon

Friday 13 January 2012 1:19:34 pm

 

Good start for eZ Persistent Object : http://share.ez.no/learn/ez-publish/a-quick-and-friendly-introduction-to-ezpersistentobject

Good start for Datatypes : http://share.ez.no/learn/ez-publish/creating-datatypes-in-ez-publish-4

You can also read the excellent article from Jérome, written for PHP Solutions Mag. last year : http://www.lolart.net/blog/ez-publish/dossier-ez-publish-dans-le-dernier-php-solutions

Last but not least, if you are willing to use eZ Find for your search feature, developing your own datatype will help you in indexing data the way you want... blunk.gif Emoticon

Hi Arnaud... I guess that nobody loves me!! sad.gif Emoticon

I took a look to the links you suggested me and that's what I discovered:

  • eZ Persistent objects: quite easy and good tutorial! But it's not enough for me to go on with my work (it helps!)
  • Datatypes: good tutorial, but completely useles without the source code... People are looking for that since 2008, so I have no hope to find it sad.gif Emoticon
  • The article of Jérome is no more available on that site

 

Any other suggestion will be really appreciated! happy.gif Emoticon

Saturday 14 January 2012 12:57:36 pm

Hi Simone, 

regarding datatypes, I'm pretty sure that there's something somewhere... please get in touch with Jérome so that he might send you the tutorial.

You can also have a look at the RAD in the Setup tab of your admin interface. It will give you the PHP class prototype with the mandatory methods. Furthermore, you should have a look at the built-in datatype such eZText (kernel/classes/datatypes/eztext/eztexttype.php) or eZDate (kernel/classes/datatypes/ezdate/ezdatetype.php). These ones are pretty simple to understand.

Cheers

Saturday 14 January 2012 1:13:37 pm

regarding datatypes, I'm pretty sure that there's something somewhere... please get in touch with Jérome so that he might send you the tutorial.

Hi Simone, 

Arnaud is right. You can get in touch with Jérôme directly here : http://share.ez.no/authorcontact/form/11256

Cheers !

Monday 16 January 2012 9:39:31 am

Hello Folks,

 

I just wanted to share that just a few hours ago we (BC) sent contact requests / emails which give all required detail regarding this issue to Jérôme and another contact at ymc.ch in the interest of trying to help resolve this problem with the missing article source code.

 

Worth mentioning we have received up to 3 recent reports that we remember of this problem in the recent past. Also we also long ago tried contacting the author using the authorcontent solution but never received any response. 

 

We hope this helps ... 

 

We will post updates here in this thread again if we receive any positive responses to our request attempts.

 

Cheers,

Heath

Monday 16 January 2012 11:32:23 am

Hi there !

I have received your requests happy.gif Emoticon.

I'm currently in the process of translating my article from french to english so that it can be published here. It is quite extensive so it can take a while, sorry.

Anyway, if you can read french, I can post it somewhere happy.gif Emoticon

Monday 16 January 2012 11:56:03 am

Hello Jérôme,

 

If you can just go ahead and "post it somewhere" if you would please

as French is not normally a language bariaer in an era where Google Translate does the heavy lifting for us English reader's brains blunk.gif Emoticon

 

No worries, just a suggestion. I'll trust that this article makes it to publication on share.ez.no and puts an 'End-Game' ending to the problems encountered within this thread (and many many others btw).

 

I hope this helps ...

 

Cheers,

Heath

Monday 16 January 2012 12:31:13 pm

And here it is : http://bit.ly/ezdatatype

Monday 16 January 2012 12:36:11 pm

And here it is : http://bit.ly/ezdatatype

Well done, nice temporary solution !

expandshrink

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

36 542 Users on board!

Forums menu