Fetch

Author Message

Rob Clews

Monday 22 December 2003 6:46:38 am

I have setup a class that includes an Object Relation, how do I find all content that links back to the current object through that relation. For example, if I have an object (a) that is linked to another object (b). How can I show in a template all objects that link to object b?

Cheers,
Rob

Balazs Halasy

Monday 22 December 2003 7:00:06 am

Yes, it is possible.

Let's say that you're viewing a node, in this case you'll have access to the $node variable. From the $node variable you can gain access to the object that this node points to. The object contains info about related objects. The following example template code shows how to get access to the related objects:

{$node.object.related_contentobject_array|attribute(show)}

This will print out info about related objects (if any).

Balazs

Rob Clews

Monday 22 December 2003 8:01:21 am

Thanks,

When viewing object a if I put

{count($node.object.related_contentobject_array)}

in the template that overrides full.tpl then I get 0 the same with object b that it points to.

In the admin the Object Relation shows up fine.

Paul Borgermans

Monday 22 December 2003 11:40:40 am

Hi Balazs

I think Rob means something else: a list of objects that link to the linked object too.

That is currently not possible. Even more, when an object relation is defined as an attribute, the link goes into the attribute values table. The code posted above is for the generic object-object relations instead.

To have that information, one should write either an operator that queries the attribute value table (or the ezcontentobject_link table for generic object-object relations) or add this as a content method to the datatype object relation.

For the datatype object relation list, this involves even XML parsing as far as I understand from the code.

It is an interesting functionality though, as it allows to build "topic maps"

-paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Rob Clews

Tuesday 23 December 2003 2:43:33 am

Paul,

Yes that is what I meant, thanks for your insight. I will look into adding an operator if I cannot find a more elegant way of doing what I want to do.

Cheers
Rob

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