how can i use the reverse_related_objects fetch function?

how can i use the reverse_related_objects fetch function?

Tuesday 03 March 2009 5:24:01 am - 8 replies

Modified on Tuesday 03 March 2009 6:53:46 am by Seb gaillard

Author Message

Jean-Yves Zinsou

Tuesday 03 March 2009 7:33:09 am

hi there,
indeed you have to use the parameter all_relations to fetch related objects that are made through an attribute of type obejct relation or object relations.

Try to set your attribute identifier by its id as integer and not as string

{def $OR = fetch( 'content', 'reverse_related_objects', 
hash( 

  'object_id', $node.contentobject_id,
  'all_relations', true(),
  'attribute_identifier', 134
) 
) }
 

for example

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Seb gaillard

Tuesday 03 March 2009 7:51:01 am

Thanks jean-Yves,

I have already tried. It doesn't work...
for example, the attribute author (id: 268) of the class book

{def $OR = fetch( 'content', 'reverse_related_objects', 
hash( 
  'object_id', $node.contentobject_id,
  'all_relations', true(),
  'attribute_identifier', 268
) 
) }

 

Jean-Yves Zinsou

Tuesday 03 March 2009 8:00:36 am

Ok,

It may sound stupid but i have come across really curious things in ez...
the following code is one that works in one of my apps

{def $related=fetch( 'content', 'reverse_related_objects',
hash( 'object_id', $pays.contentobject_id ,
'attribute_identifier','user/managed_countries',
'all_relations',true()))}

The only difference is the all_relations at the end of the statement...Give it a try !
Does not cost a thing ...
hth

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Seb gaillard

Tuesday 03 March 2009 8:54:55 am

Argh,

I've tried this... and it doesn't work!

{def $livres = fetch( 'content', 'reverse_related_objects',
	hash( 'object_id', $node.contentobject_id,
		'attribute_identifier', 570,
		'all_relations', true()
               )
   )
}

Are you using eZ 4.0.1 ???

Jean-Yves Zinsou

Tuesday 03 March 2009 9:04:03 am

bonjour ;-)

haven't you say that the attribute identifier of the author attribute in book class was 268 ?

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Seb gaillard

Tuesday 03 March 2009 9:13:16 am

Re,

I used 268 for example.
I don't make mistake (ok, i don't speak a good english...) about the id.

Jean-Yves Zinsou

Tuesday 03 March 2009 9:27:15 am

Well,
sorry not to be of any help,
My apps started in ez 4.0.1 an has been migrated in 4.0.2...
And it works...

If it does not on your app, and if there are no errors in the error.log, i really don't know what to say...

Please tell me when you find out what was wrong ...

Do Androids Dream of Electric Sheep?
I dream of eZpubliSheep....
------------------------------------------------------------------------
http://www.alma.fr

Patrick Renaud

Wednesday 04 March 2009 1:11:41 am

Hi Seb,
Have you tried using only hard-coded values ? Without the "all_relations" parameter, useless when you specify the attribute ?

{def $OR = fetch( 'content', 'reverse_related_objects', 
hash( 
  'object_id', 1234,
  'attribute_identifier', 268
) 
) }

Ca, c'est fait !

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

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