Displaying contents from subfolders

Author Message

Tom Erik Thorsen

Monday 29 September 2003 5:42:49 am

OK, lets say I have a folder with several sub-cats.

For example:
Cat 1
- sub 1.1
- sub 1.2
- sub 1.3
- sub 1.4
--sub 1.4.1
- sub 1.5
Cat 2
- sub 2.1
...and so on....

What I want to do, is to display the contents (which is articles)from all subfolders from cat1.

Any ideas?

PS! Great CMS, though a bit hard to get "under the hood" ;)

Paolo Tramontani

Monday 29 September 2003 9:42:39 am

Normally fetch instruction retrieve only 1-level children.
This is the code:

{section name=myloop loop=fetch( content, list, hash( parent_node_id, $node.node_id )}
<div>
{node_view_gui view=line content_node=$myloop:item}
</div>
{/section}

This code retrieve only the children of your main folder so it display 1.1, 1.2, ..., 1.5 but not 1.4.1
If you want display every level in the subtree you have only to change the second parameter in the fetch function from "list" to "tree":

{section name=myloop loop=fetch( content, tree, hash( ...

Unfortunately this code don't distinguish the level and you'll find all nodes displayed in the same way. You have to add other code to indent or distinguish the level of each node. If you have only two level you can try to use the $myloop:item.parent_node_id.
Otherwise you should search in the docs some other property that indicate the deep of the node.

If you discover something interesting about it let us know,
Paolo

Albert Berenguer

Thursday 02 October 2003 8:49:56 am

hi, i found a way to do it...
it only displays the folders (or any content) contained by the actual node and also the content of theese folders, it also provides the links to them.

Here it goes:

{let folder_list=fetch('content','list',hash(parent_node_id, $node.node_id)}
{section name=Folder loop=$folder_list}
<a href={concat("/content/view/full/", $Folder:item.node_id,"/")|ezurl}>{$Folder:item.name|wash}</a><br>

{let subfolder_list=fetch('content','list',hash(parent_node_id, $Folder:item.node_id)}
{section name=Subfolder loop=$Folder:subfolder_list}
 <a href={concat("/content/view/full/", $Folder:Subfolder:item.node_id,"/")|ezurl}>{$Folder:Subfolder:item.name|wash}</a><br>
{/section}
{/let}

{/section}
{/let}

if you only want to display folders, and not other content (sthg useful for menus and so), replace the corresponding lines of the code below with theese:

{let folder_list=fetch('content','list',hash(parent_node_id, $node.node_id,),class_filter_type,"include",class_filter_array,array(1)))}

{let subfolder_list=fetch('content','list',hash(parent_node_id, $Folder:item.node_id,),class_filter_type,"include",class_filter_array,array(1)))}

i hope it helps you, bye!!

PS: Paolo, i found an attribute called 'depth' which provides de depth of a node, in your example the code would be "$myloop:item.depth"

berto

Gard Guldhav

Wednesday 08 October 2003 9:43:39 am

I have just started using ezpublish for a site and have a need for several sub-cats...
The code probably works but where should i put it?

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