The best way to relate objects?

Author Message

krish harry

Saturday 24 May 2003 1:52:46 am

Why we are not able to relate multipe objects using "Object relation" datatype? Or am i missing something?

Because of the above making a simple structure like below is cubersome:
Class Course
related instructors
related courses
related schedules
end

We cannot use the built in related object functionality as it invovels double work -- first selecting objects and then putting in xml text field.

I am wondering if you guys are not facing this difficulty of "Object relation" datatype accepting only one object. Also then what other best way you have achieved solution to this?

Jo Henrik Endrerud

Sunday 25 May 2003 1:16:12 pm

The Object Relation datatype meant to be used the times you need to force the author to relate another object (or by adding more of this attribute, deveral objects).

The way we solve your problem is by using th enormal related object functionality. If you don't want to make the user add the objects without making them put the text in the xml field you should modify the template to present the related objects in the way you want to present them. Then you can make lists with your related objects without them having to be added in the xml text field

Jo Henrik Endrerud | System Developer @ Seeds Consulting | http://www.seeds.no

krish harry

Sunday 25 May 2003 10:16:50 pm

Thats a very good idea. Thanks.

Linking different types of multiple objects through different "Object relation" attributes would have been much better as it would bifergate the different types of relations. But your idea is also good.

Does anybody know the sample of template code for viewing all the related objects (linked through built-in related object functionality) ?

Also for viewing only the related objects of specific class?

tx
krish

Thomas Thiel

Tuesday 10 June 2003 11:28:25 am

Hi,

maybe here is something whats in your mind:

http://www.radiologie-weinheim.de/content/view/full/93/

I made a custom folder and an custom article-class to show the content the way it does. together with some css-magic its displaying this way. build an override-template for the specific custom folder:

{default with_children=true()}
{let list_count=and($with_children,fetch('content','list_count',hash(parent_node_id,$node.node_id)))}

{default content_object=$node.object
content_version=$node.contentobject_version_object}

<table class="linklist" width="100%" cellpadding="3" cellspacing="3" border="0">
<tr>
<th style="border: thin solid black;" align="left">Untersuchung</th><th align="left" style="border: thin solid black;">Anmeldung</th><th align="left" style="border: thin solid black;">Vorbereitung</th><th align="left" style="border: thin solid black;">Dauer(in Minuten)</th>
</tr>
{let name=Child
children=fetch('content','list',hash(parent_node_id, $node.node_id, sort_by, array(array(priority))))}
{section loop=$:children sequence=array(bglight,bgdark)}
<tr>
{node_view_gui view=line content_node=$Child:item}
</tr>
{/section}
</table>

{/let}
{/default}
{/let}
{/default}

I'm sure it can be done in a more elegant way. a big problem is that the template is incredible slow if there is no object relation defined. but i think one can use the new is_empty-function to solve this pitfall. btw: does anybody have an idea how the table-rows can be showed bglight-bgdark ? did not solve this problem with the above stated code.

Regards, Thomas

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