Forums / Setup & design / About fetching children

About fetching children

Author Message

Pascal France

Tuesday 12 May 2009 7:24:54 am

Hi,

I have a tree which looks like that:

level1
  |---item1
         |----child1
         |----child2
         |----child3
  |---item2
         |----child1
         |----child2
  |---item3
         |----child1
         |----child2
         |----child3

Is there a way to fetch, with a single fetch, each first child of each <i>item</i> nodes ?

In fact, I would like to create a menu

|  item1  |  item2  |  item3  |

where each item is a link to its first child, and I would like to optimize the number of db queries.

Pascal

Ce qui embellit le désert c'est qu'il cache un puits... quelque part... (A. de Saint-Exupéry) - http://luxpopuli.fr/eZ-Publish

Ivo Lukac

Tuesday 12 May 2009 8:50:49 am

You can try with priority. Set priority sorting for item objects and enter for example priority 0 to first object.
Then with fetch tree function filter only priority = 0.
This is just an idea, I didn't do it :)

http://www.linkedin.com/in/ivolukac
http://www.netgen.hr/eng/blog
http://twitter.com/ilukac

Jean-Luc Nguyen

Wednesday 13 May 2009 6:56:41 am

Hello,

When you have the items array, you can get its children, something like $items.children.0...

http://www.acidre.com

Michael Fürst

Thursday 14 May 2009 2:36:20 am

Hi,

Yeah, you are of course able to fetch only the items on level 1.
Here's my example of fetching the menu:

{def $menuTop=fetch( content, list, hash( 	
    parent_node_id, $indexpage,
    sort_by, array('priority',true), 
    class_filter_type, include,
    class_filter_array, array('frontpage','link','contentpage','event_calendar','blog','internal_shortcut','bildergalerie','folder')))
}

$indexpage is the node ID of the root node - in your case "level1".
Additionally you can use the "depth" parameter to define how many levels shall be fetched. http://ez.no/doc/ez_publish/technical_manual/4_0/reference/modules/content/fetch_functions/list

Cheers,
Mike