eZ Community » Forums » Developer » Fetches reverse related objects on...
expandshrink

Fetches reverse related objects on multiple attributes

Fetches reverse related objects on multiple attributes

Tuesday 27 January 2015 6:21:03 pm - 3 replies

Hello,

Do you know how can i fetch reverse related objects based on multiple attributes in a template?

The function reverse_related_objects works only for one attribute but how can we do for many attributes of the same class?

Thank you for your help.

Tuesday 27 January 2015 8:20:32 pm

Hello anwar,

The simplest solution would be to use multiple fetches and merge the results (as needed).

I've done this myself many times to achieve the results needed.

EDIT: I have actually written a tpl code example of this since this question was asked recently, http://share.ez.no/forums/general...e_identifier-array-instead-single-id

I hope this helps!

Cheers,
Heath 

Modified on Tuesday 27 January 2015 10:39:44 pm by // Heath

Wednesday 28 January 2015 10:22:59 am

Thank you I was thinking about this solution. Do you know how can we extend this function to receive an array instead of an attribute as parameter?

Modified on Wednesday 28 January 2015 10:47:09 am by anwar korti

Wednesday 28 January 2015 8:06:37 pm

Hello anwar,

You should not hack the kernel in search of a core solution when you should instead create a custom fetch function within a custom extension.

http://www.ezpedia.org/ez/custom_fetch

You could submit a pull request to add this functionality into the default distribution if you find a compatible solution, https://github.com/ezsystems/ezpublish-legacy/pulls

Here is the code in question: https://github.com/ezsystems/ezpu...zcontentfunctioncollection.php#L1375

But be warned that since legacy is being replaced, I'm not sure you will get much support for a solution which is technically not required and may introduce backwards compatibility issues.

Best wishes!

I hope this helps!

Cheers,
Heath 

expandshrink

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

36 542 Users on board!

Forums menu

Proudly Developed with from