Forums / Developer / Reverse Object Relations

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.

eZ debug

Timing: Jan 18 2025 16:09:49
Script start
Timing: Jan 18 2025 16:09:49
Module start 'content'
Timing: Jan 18 2025 16:09:50
Module end 'content'
Timing: Jan 18 2025 16:09:50
Script end

Main resources:

Total runtime0.9372 sec
Peak memory usage4,096.0000 KB
Database Queries204

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 589.1406180.8359
Module start 'content' 0.00740.8065 769.9766639.0000
Module end 'content' 0.81390.1232 1,408.9766337.0625
Script end 0.9371  1,746.0391 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00420.4510210.0002
Check MTime0.00160.1711210.0001
Mysql Total
Database connection0.00100.109810.0010
Mysqli_queries0.866392.43782040.0042
Looping result0.00210.22122020.0000
Template Total0.909597.020.4548
Template load0.00200.213420.0010
Template processing0.907596.835120.4538
Template load and register function0.00020.019810.0002
states
state_id_array0.00070.074310.0007
state_identifier_array0.00110.116520.0005
Override
Cache load0.00160.1735340.0000
Sytem overhead
Fetch class attribute can translate value0.00130.134650.0003
Fetch class attribute name0.00120.126370.0002
XML
Image XML parsing0.00140.148450.0003
class_abstraction
Instantiating content class attribute0.00000.001870.0000
General
dbfile0.00190.2017340.0001
String conversion0.00000.000830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
5content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 18
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs