Forums / Setup & design / Using fetch() to recurse through a tree

Using fetch() to recurse through a tree

Author Message

Tristan Koen

Friday 25 July 2003 2:51:27 am

Hi All,

I would like to find out if there is any way to make the fetch() function recurse through a tree structure. If I have a folder structure containing articles that look like:

Root Folder
- Article a
- Article b
- Folder 1
- - Article 1a
- - Article 1b
- - Folder 2
- - - Article 2a
- - - Article 2b
Article

I would like a fetch() function that will return
Article 1
Article 2
Article 1a
Article 1b
Article 2a
Article 2b

A nested fetch will not work in my case because
1. The data has to be part of the same resultset (for sorting, etc)
2. The tree can be N levels deep

I am absolutely convinced that this can be done - I just can't figure out how. Any help/suggestions will be fantastic.

Thanks

Tristan

Bjørn Kaarstein

Friday 25 July 2003 4:30:32 am

Have you seen this?

http://ezwiki.blanko.info/index.php/3XHT_TmplObjTree

Regards Bjørn

Roy Viggo Pedersen

Wednesday 30 July 2003 4:33:29 am

Try this example from the demo site (pagelayout_news.tpl):

{let news_list=fetch( content, tree, hash(
parent_node_id, 17,
limit, 5,
sort_by, array( published, false() ),
class_filter_type, include,
class_filter_array, array( 2 )) ) }

Roy