Linking objects to other objects

Author Message

Sophi Italy

Thursday 08 May 2003 9:55:47 am

After looking at the SDK docs, I understand that:
1. I can have attributes that are strings, xml content, etc.
2. An object can have an undiscriminated set of "related objects".

What I want to do is to have named attributes that link to other (sets of) objects. e.g.
Review
....
Car
year: String
favorable_reviews: Set of Reviews
unfavorable_review: Set of Reviews

Is this possble? If so, how do I do it, and is there some doc I could read? If not, is this something planned?

Thanks!

Marco Zinn

Thursday 08 May 2003 11:25:08 am

I think, the "related object" concept is what you need here.
You will have your reviews somewhere (objects of class "Review"). Then you would create your "car" object and add the corresponding objects with "Related objects".
You can then insert the "related objects" somewhere in your car object (in some XML field), each at it's own, individual position in the text.
This will display the "line" view of each review object. The "line" display usually display a simple text line (ie. the title of the review) with a HTML link to the review.

This is a "freeform" approach to it, you need to insert the related objects manually.
When you have some more structure (ie. one review is exactly for one car object), you might consider storing the review object as "children" (kind of "sub-objects") of the car object. Thus, you should be able to display the full car-object with the line-view of the children objects automatically.
I hope, some others will comment on this and agree (or prove me wrong).

Marco
http://www.hyperroad-design.com

Sophi Italy

Friday 09 May 2003 10:37:05 am

If I understand you correctly (and based on limited knowledge of eZ), you are suggesting one of two things:

a) "related object" : I can add any related objects to each Car object. But can I distinguish between them (in code, not in text) e.g. which are the favorable_reviews and unfavorable_reviews? If I were programming this in an OO language, my Car would have two separate attributes holding onto each set of review objects.

b) "child objects" : But then am I limited to a review for only one Car? i.e. a tree structure of objects?

I think both (a) and (b) are very useful. However an important case is missing: when I want to add named links (as I would do with attributes in an OOPL) to my graph of objects that are not "tree" links.

Also, could you be kind enough to point at where in the docs I might read more about "related objects" and "child objects"?

Thanks.

josh r

Sunday 11 May 2003 4:02:38 pm

wait... if this is really an object oriented system, then the link between related objects should be enough, no? you shouldn't need to store the name of each object on it's own line in an xml field, or am I misunderstanding this?

(I'm trying to figure out how to link objects too. I'd like to link an address to my users)

Sophi Italy

Wednesday 14 May 2003 2:14:44 pm

I will try a clearer example (while trying to find answers in the eZ docs).

If I have objects r1, r2, r3, ...r19, r20 : Review
..and object M500 : Car
..and
... the name of M500 = "Mercedes S500"
... M500 has 9 reviews: r1, r2, ...r9
... M500 has 3 good reviews: r1, r2, r3
... M500 has 2 bad reviews: r19, r20
... M500 has the best review: r1

How should I associate the objects or values "Mercedes S500", {r1...r9}, {r1..r3}, {r19,r20}, and r1, with the "name", "reviews", "good reviews", "bad reviews", and "best review" of the object M500?

Should they not ALL be just attributes on the class Car? Why should I need different concepts (attribute, object relation, related objects, XML fields)? Even if eZ deals with them differently behind the scenes, why should they be different to the one defining Car?

Thanks.

Paul Forsyth

Thursday 15 May 2003 1:30:59 am

If i read you correctly then ez doesn't support this in the manner you describe. You can't include a class as an attribute. They are totally seperate.

A related object is only related if you add it to an object. Nothing more is implied, in my understanding.

However, you can write template code to 'do' what you need.

In order to infer more about the relation you need to write template logic to identify what one means to the other.

In your example your review may be a related object, but this may be cumbersome since you would need to add related object reviews for each new car... It may be better to examine the results from a fetch over all reviews, then examine which reviews concerned your M500 car. And from this you can further examine the conclusion of the review and present the results.

Hope this helps,

Paul

Ps. I wish there was a way to include a class as an attribute!

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.