Reverse Object Relations

Author Message

josh rowley

Wednesday 30 January 2008 5:04:54 am

Hi!

I'm looking for a way to fetch a list of objects by reverse object relation ( multi select ).

So, currently I have an objectrelations attribute within a series of objects I want to search for, that points to a subtree. I want to be able to pass a list of node ids from that subtree to a fetch function that will return objects which are related to all of the node ids that are requested.

Now, I see that you cannot do attribute filtering with the objectrelations datatype. Does the enhanced object relations do what I want, do I need a SQL filter, or can anyone make any other suggestions of how I might achieve this, or how it has been solved in the past?

Many Thanks!

Felix Laate

Wednesday 30 January 2008 11:54:17 am

Hi Josh!

Welcome to the community!

A good place to start would be here:

http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/reverse_related_objects

This function supports attribute filtering as well.

Cheers!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

josh rowley

Thursday 31 January 2008 1:56:37 am

Thanks Felix!

However, I have seen that document already and it doesn't look like I can fetch by multiple relations.

The only way I can see to do this, as underneath the objectrelations datatype uses XML in the data_text field to store the relations, is to do multiple fetches ( one per relation I want to match on ) and then build an array of node_ids that have objects which match all 3 requests.

Pretty inefficient.. Another way I can think is to create a new datatype which uses the object link table instead of XML.. but I wonder if there are any solutions out there which will already work with a simple fetch using attribute filters.

Josh

André R.

Thursday 31 January 2008 3:27:50 am

object relationlist already use the object link table, look at this extension for code (it uses the extended object attribute filter for relations filtering).

Relations filter ( comment by Kristof Coomans ):
http://ez.no/developer/contribs/template_plugins/objectrelationfilter

Reverse relations filter:
http://pubsvn.ez.no/community/trunk/extension/objectrelationfilter/classes/objectrelationfilterandinv.php

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

John Kazakis

Thursday 12 June 2008 8:49:54 am

Hello,

Is there a way to fetch reverse_related_objects AND related_objects? Or do I have to use 2 separate fetches?

Thanks.

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

eZ debug

Timing: Jan 31 2025 04:33:41
Script start
Timing: Jan 31 2025 04:33:41
Module start 'layout'
Timing: Jan 31 2025 04:33:41
Module start 'content'
Timing: Jan 31 2025 04:33:41
Module end 'content'
Timing: Jan 31 2025 04:33:41
Script end

Main resources:

Total runtime0.0133 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.1328151.2109
Module start 'layout' 0.00450.0022 739.343836.6484
Module start 'content' 0.00670.0052 775.992294.1406
Module end 'content' 0.01190.0014 870.132833.9922
Script end 0.0133  904.1250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002418.1898140.0002
Check MTime0.00129.3504140.0001
Mysql Total
Database connection0.00075.037310.0007
Mysqli_queries0.002216.284230.0007
Looping result0.00000.089610.0000
Template Total0.00118.010.0011
Template load0.00086.218610.0008
Template processing0.00021.753210.0002
Override
Cache load0.00064.262910.0006
General
dbfile0.00139.422180.0002
String conversion0.00000.060940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs