sort within tree

Author Message

Nick Ursa

Thursday 21 December 2006 4:31:25 am

I'm having trouble getting ezpublish to respect the priority when using fetch content tree:

When I do:

{def $items=fetch( 'content', 'tree', hash( 'parent_node_id',$top_node_to_fetch,
                                            sort_by, array('priority', true())
                                             )))}

It doesn't sort each group of children but rather sorts the whole list after the initial search, destroying the hierarchy.

What I would have expected is that, starting from the parent node, it sorts the subchildren, outputs the first item, and checks for children, then sorting those subchildren, etc, before output. Currently fetch-tree behaves exactly like list.

All I want is to control the order of items within the tree. Any suggestions ?

Claudia Kosny

Thursday 21 December 2006 11:03:00 am

Hi Nick

If you check the SQL query that is created by this fetch function you can see that this is not possible. The result you want to have is only possible if you fetch the children of each child recursively with a separate query which is not possible with an eZ template function/operator (unless you write your own, which is fairly easy to do).

The only difference between tree and list is that list fetches only direct children of a node, otherwise they are the same.

Claudia

Piotrek Karaƛ

Wednesday 11 April 2007 3:24:39 pm

To be honest, I don't quite grasp the difference (or any useful difference to be precise) between list and tree content fetches. Both use the depth parameter, which makes them even more alike. And the name 'tree' is definitely misleading since there's little that we can do with the result as a tree. Can anyone give a useful example of tree fetch implementation?
Thanks!

--
Company: mediaSELF Sp. z o.o., http://www.mediaself.pl
eZ references: http://ez.no/partners/worldwide_partners/mediaself
eZ certified developer: http://ez.no/certification/verify/272585
eZ blog: http://ez.ryba.eu

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