Forums / Setup & design / Fetching list of nodes with array of node_ids
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
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!
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