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.

eZ debug

Timing: Jan 31 2025 06:29:08
Script start
Timing: Jan 31 2025 06:29:08
Module start 'layout'
Timing: Jan 31 2025 06:29:08
Module start 'content'
Timing: Jan 31 2025 06:29:08
Module end 'content'
Timing: Jan 31 2025 06:29:08
Script end

Main resources:

Total runtime0.0123 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0046 588.2500151.2266
Module start 'layout' 0.00460.0021 739.476636.6641
Module start 'content' 0.00670.0045 776.140694.0313
Module end 'content' 0.01120.0011 870.171933.9922
Script end 0.0123  904.1641 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002117.4046140.0002
Check MTime0.00097.6404140.0001
Mysql Total
Database connection0.00086.118110.0008
Mysqli_queries0.002016.429730.0007
Looping result0.00000.073510.0000
Template Total0.00097.110.0009
Template load0.00065.201310.0006
Template processing0.00021.816310.0002
Override
Cache load0.00053.690610.0005
General
dbfile0.00119.087280.0001
String conversion0.00000.048440.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs