Fetching list of nodes with array of node_ids

Author Message

V. van Velzen

Tuesday 15 September 2009 1:04:40 am

Good morning,

I'm trying to fetch a list of (reverse related) nodes sorted on a specific attribute. Because the option 'reverse_related_objects' does not support the sort_by attribute, I thought to follow the proces below:
1) Fetch array of node_ids using fetch('content','reverse_related_objects_ids');
2) Fetch array of nodes with the above node_ids, sorted on the attribute.

Step 2 doesn't seem to be possible in EZ, though. It's either getting the data of a node with one specific node_id or getting an array of nodes belonging to a specific parent_node_id.

So, my questions are:
a) is it possible to fetch an array of reverse_related_objects sorted by a specific attribute (my preferred method that does not seem to work (but maybe I'm missing something));
b) if not, is it possible to fetch an array of nodes using an array of node_ids?

TIA,

Vivienne

André R.

Tuesday 15 September 2009 2:07:19 am

a) Actually, it seems to be (almost?) support as eZContentObjectTreeNode::createSortingSQLStrings is used in eZContentObject::relatedObjects. So have you tried it even if it isn't documented?

b) That is possible as of 4.2, with the introduction of node_id and contentobject_id filters and storing options.

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

V. van Velzen

Tuesday 15 September 2009 7:50:02 pm

Good morning André,

Actually, I have tried using the attribute_id as a sorting option. In combination with setting the option 'attribute_identifier' this caused a MySQL error (eZMySQLDB: Column 'contentclassattribute_id' in where clause is ambiguous.) and seeing as the documentation said that this sorting option was not supported I concluded that it wasn't possible.

Just now I dropped the 'attribute_identifier' option and used 'all_relations' and this appears to work in combination with the unsupported sorting option (at least I'm not getting any errors). So now I'm checking on the existence of the attribute identifier in the returned resultset and it seems that I'm in business :-).
Thanx!

André R.

Wednesday 16 September 2009 3:16:15 am

Ok, thanks for reporting it.

Added a issue for it so we can track it:
http://issues.ez.no/IssueView.php?Id=15497&activeItem=1

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

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 30 2025 22:25:53
Script start
Timing: Jan 30 2025 22:25:53
Module start 'layout'
Timing: Jan 30 2025 22:25:53
Module start 'content'
Timing: Jan 30 2025 22:25:54
Module end 'content'
Timing: Jan 30 2025 22:25:54
Script end

Main resources:

Total runtime0.9865 sec
Peak memory usage8,192.0000 KB
Database Queries60

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0045 588.2656151.2266
Module start 'layout' 0.00450.0032 739.4922220.7188
Module start 'content' 0.00770.9779 960.21094,460.1016
Module end 'content' 0.98560.0008 5,420.312511.8125
Script end 0.9865  5,432.1250 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00350.3503160.0002
Check MTime0.00120.1267160.0001
Mysql Total
Database connection0.00060.060310.0006
Mysqli_queries0.907892.0264600.0151
Looping result0.00050.0477580.0000
Template Total0.942495.520.4712
Template load0.00220.223420.0011
Template processing0.940295.311120.4701
Template load and register function0.00130.128010.0013
states
state_id_array0.00130.130110.0013
state_identifier_array0.00140.138120.0007
Override
Cache load0.00190.1894270.0001
Sytem overhead
Fetch class attribute can translate value0.00140.146820.0007
Fetch class attribute name0.00170.170650.0003
XML
Image XML parsing0.00070.067820.0003
class_abstraction
Instantiating content class attribute0.00000.001360.0000
General
dbfile0.00110.1084170.0001
String conversion0.00000.000740.0000
Note: percentages do not add up to 100% because some accumulators overlap

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
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
8content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
4content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 20
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs